[Python-3000] Efficient LC's which don't leak the iteration variables (was Re: Py3k release schedule worries)
jimjjewett at gmail.com
Wed Dec 20 21:38:48 CET 2006
On 12/20/06, Guido van Rossum <guido at python.org> wrote:
> On 12/20/06, Nick Coghlan <ncoghlan at gmail.com> wrote:
> > I haven't actually tried to implement that, though, and I suspect things will
> > get a little tricky when it comes to dealing with nested scopes like '[(lambda
> > i=i: i) for i in range(10)]'.
> That doesn't strike me as tricky; I expect it'll happen automatically
> if you do the right thing.
[(lambda i=i: i) for i in range(10)]
[(lambda i=0_i: i) for 0_i in range(10)]
The argument to lambda can't be renamed, because it could be called as
Knowing which i's to rename strikes *me* as tricky, to the point where
I would suggest at least considering a "works as implemented"
pronouncement. This (along with further nesting, closure variables,
conditionally defined variables, etc) is obscure enough that backwards
incompatibility could be justified, if it made the explanation (or
More information about the Python-3000