Ensure unwanted names removed in class definition

Ben Finney ben+python at benfinney.id.au
Thu Aug 13 08:04:06 CEST 2015

Peter Otten <__peter__ at web.de> writes:

> Ben Finney wrote:
> > Peter Otten <__peter__ at web.de> writes:
> > 
> > That's an unexpected inconsistency between list comprehensions
> > versus generator expressions, then. Is that documented explicitly in
> > the Python 2 documentation?
> https://docs.python.org/2.4/whatsnew/node4.html

Or <URL:https://docs.python.org/2/whatsnew/2.4.html#pep-289-generator-expressions>.

Also in the PEP that introduces generator expressions, PEP 289:

    List comprehensions also "leak" their loop variable into the
    surrounding scope. This will also change in Python 3.0, so that the
    semantic definition of a list comprehension in Python 3.0 will be
    equivalent to list(<generator expression>).


Thanks for seeking the answer. Can you describe an improvement to
that makes clear this unexpected, deprecated behaviour which is only in
Python 2?

 \     “What is needed is not the will to believe but the will to find |
  `\       out, which is the exact opposite.” —Bertrand Russell, _Free |
_o__)                           Thought and Official Propaganda_, 1928 |
Ben Finney

More information about the Python-list mailing list