I ran the following code:
import itertools
my_list = ['a', 'b', 'c', 'd', 'e']
for i in itertools.izip([x for x in my_list], [y for y in itertools.count()]):
print i
Based on the documentation for izip, I expected it to return a series of tuples, ending when my_list ran out: (a,0) (b,1) (c,2) (d,3) (e,4)
Instead, I get the memory error copied below. It seems the itertools.count() function is returning infinite data, rather than being limited to the 5 records in my_list?
line 50, in main
for i in itertools.izip([x for x in range(10)], [y for y in itertools.count()]): MemoryError