Python: use izip for iterating over multiple lists
I know I'll forget this again, so I'll blog it.
from itertools import izipThis also works for more than two lists. Zip() and map() also work but izip() should use less memory and perh
xlist = [1, 2, 3]
ylist = [5, 6, 7]
for x, y in izip(xlist, ylist):
print x, y
Outputs:
1 5
2 6
3 7
Comments