Basically, I'm in following situation - I generate a list, e.g.
l = [2*x for x in range(10)]
which I iterate through later on multipletimes, e.g.
for i in l: print i # 0,2,4,6,8,10,12,14,16,18
for i in l: print i # 0,2,4,6,8,10,12,14,16,18
for i in l: print i # 0,2,4,6,8,10,12,14,16,18
The problem is that the list is way too large to fit into memory, hence I use its generator form, i.e.:
l = (2*x for x in range(10))
However, after this construction only first iteration works:
for i in l: print i # 0,2,4,6,8,10,12,14,16,18
for i in l: print i #
for i in l: print i #
Where is the problem? How may I iterate through it multipletimes?