Christopher King added the comment:
This is a crazy and unexpected behavior. (Moreover, the fact that Python has
dynamic scope *only if you forget to initialize a variable* is even more crazy
and unexpected.) To provide unsurprising behavior (i.e. behavior compatible
with that of a list
Christopher King added the comment:
Also tested and broken in Py3k.
--
versions: +Python 3.2
___
Python tracker
<http://bugs.python.org/issue7423>
___
___
Pytho
Christopher King added the comment:
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
Christopher King added the comment:
Quote from Guido:
"""In general the value of every free variable used anywhere
except in the outer expression should be captured; [...] This
should give the least surprising semantics in a variaty of use
cases."""
Christopher King added the comment:
> I hear what you are saying, but the "generalization" does not mean
> that they work exactly the same way.
Correct. But it does mean that the functionality of one (generator
expressions) is a superset of the functionality of the other (list
Christopher King added the comment:
*At this point you need to take your arguments to python-ideas or python-dev
(probably the latter),*
I used Python once and will probably never use it again. I'm not nearly
invested enough to evangelize on several mailing lists the validity of a bug