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 Christopher.King
Recipients Christopher.King, benjamin.peterson, bogklug, r.david.murray
Date 2013-02-26.20:14:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1361909698.39.0.566010761402.issue7423@psf.upfronthosting.co.za>
In-reply-to
Content
Only the implementation of *generators* needs to change to remedy this bug.  Please see the example I included.  By closing the generated generator function over free the free variables in the generator expression, you can avoid dynamic scoping entirely and provide expected behavior.

The reason I claim this behavior is surprising and incorrect is because generator expressions are touted as being able to replace list comprehensions, when in fact they are not due to this bug.  Even the generator expression PEP claims: "This PEP introduces generator expressions as a high performance, memory efficient generalization of list comprehensions".

Until this bug is fixed, generator expressions are NOT a generalization of list comprehensions, and hence CPython is in violation of the PEP as accepted.
History
Date User Action Args
2013-02-26 20:14:58Christopher.Kingsetrecipients: + Christopher.King, benjamin.peterson, r.david.murray, bogklug
2013-02-26 20:14:58Christopher.Kingsetmessageid: <1361909698.39.0.566010761402.issue7423@psf.upfronthosting.co.za>
2013-02-26 20:14:58Christopher.Kinglinkissue7423 messages
2013-02-26 20:14:58Christopher.Kingcreate