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 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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue7423>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to