[New-bugs-announce] [issue5968] Generator expression bug?
Sven Rahmann
report at bugs.python.org
Fri May 8 15:24:50 CEST 2009
New submission from Sven Rahmann <svenrahmann at googlemail.com>:
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.
----------
files: generatorbug1.py
messages: 87440
nosy: svenrahmann
severity: normal
status: open
title: Generator expression bug?
type: behavior
versions: Python 2.4, Python 2.5, Python 2.6, Python 2.7, Python 3.0, Python 3.1
Added file: http://bugs.python.org/file13923/generatorbug1.py
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5968>
_______________________________________
More information about the New-bugs-announce
mailing list