This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author svenrahmann
Recipients svenrahmann
Date 2009-05-08.13:24:48
SpamBayes Score 3.316165e-06
Marked as misclassified No
Message-id <1241789090.54.0.0922796192042.issue5968@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2009-05-08 13:24:50svenrahmannsetrecipients: + svenrahmann
2009-05-08 13:24:50svenrahmannsetmessageid: <1241789090.54.0.0922796192042.issue5968@psf.upfronthosting.co.za>
2009-05-08 13:24:49svenrahmannlinkissue5968 messages
2009-05-08 13:24:49svenrahmanncreate