I have a python script, in which I do the following at one point:
iterator = product(*izip(repeat(0,len(myList)),myList))
I use the python command line, and do execfile('myScript.py')
. After the code has run, I try the following:
>>> iterator
<itertools.product object at 0x182f06370>
>>> list(iterator)
[]
However, if I place a print statement in the script print list(iterator)
right after iterator
has been generated, the code prints the elements of the list correctly.
Why do the elements disappear after the file execution is done? Is this normal behavior?