I know that it's possible to convert generators into lists at a "low-level" (eg. list(i for i in xrange(10))
), but is it possible to do the reverse without iterating through the list first (eg. (i for i in range(10))
)?
Edit: removed the word cast
for clarity in what I'm trying to achieve.
Edit 2: Actually, I think I may have misunderstood generators at a fundamental level. That'll teach me to not post SO questions before my morning coffee!
Try this: an_iterator = iter(a_list)
... docs here. Is that what you want?