Message87440
Lists from list comprehensions and generator objects from generator
expressions behave differently when we repeatedly want to iterate over them.
This may or may not be a bug, but it is certainly not clear from the
documentation (see documentation of "for" statement in all recent python
versions).
The reason seems to be that generator expressions, once exhausted, are
not reset by using them again in a for loop.
This is different for lists and range objects.
The attached example illustrates the phenomenon.
It is written for Python 3, but the same phenomenon occurs in the 2.x
series. |
|
Date |
User |
Action |
Args |
2009-05-08 13:24:50 | svenrahmann | set | recipients:
+ svenrahmann |
2009-05-08 13:24:50 | svenrahmann | set | messageid: <1241789090.54.0.0922796192042.issue5968@psf.upfronthosting.co.za> |
2009-05-08 13:24:49 | svenrahmann | link | issue5968 messages |
2009-05-08 13:24:49 | svenrahmann | create | |
|