subtle side effect of generator/generator expression
bonono at gmail.com
bonono at gmail.com
Sun Oct 16 09:42:38 EDT 2005
Hi,
I initially thought that generator/generator expression is cool(sort of
like the lazy evaluation in Haskell) until I notice this side effect.
>>>a=(x for x in range(2))
>>>list(a)
[1,2]
>>>list(a)
[]
Would this make generator/generator expression's usage pretty limited ?
As when the program/system goes beyond a single module, this behaviour
can cause subtle bugs ?
More information about the Python-list
mailing list