Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #95333 > unrolled thread
| Started by | Peter Otten <__peter__@web.de> |
|---|---|
| First post | 2015-08-13 07:44 +0200 |
| Last post | 2015-08-13 07:44 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Ensure unwanted names removed in class definition Peter Otten <__peter__@web.de> - 2015-08-13 07:44 +0200
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2015-08-13 07:44 +0200 |
| Subject | Re: Ensure unwanted names removed in class definition |
| Message-ID | <mailman.156.1439444692.3627.python-list@python.org> |
Ben Finney wrote: > Peter Otten <__peter__@web.de> writes: > >> I would probably use a generator expression. These don't leak names: > > 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/reference/expressions.html has one sentence """ Note that the comprehension is executed in a separate scope, so names assigned to in the target list don’t “leak” in the enclosing scope. """ -- which is wrong unless I'm misunderstanding something, but https://docs.python.org/2.4/whatsnew/node4.html clearly states """ Generator expressions differ from list comprehensions in various small ways. Most notably, the loop variable (obj in the above example) is not accessible outside of the generator expression. List comprehensions leave the variable assigned to its last value; future versions of Python will change this, making list comprehensions match generator expressions in this respect. """
Back to top | Article view | comp.lang.python
csiph-web