On Mon, Jul 5, 2010 at 11:12 PM, Tim Golden <m...@timgolden.me.uk> wrote:
> I had understood (without being able to put my finger on a relevant thread)
> that all comprehensions were going not leak their loop variables in the
> future.

This understanding is correct (with that future being Python 3.x where
all comprehensions have their own private scope).

As others have noted, generator expressions in 2.x already didn't leak
the iteration variable into the surrounding scope.

The only reason list comprehensions continue to leak the iteration
variable in 2.6 and 2.7 is that there *is* code out there that relies
on that behaviour. However, since legacy code can't include set or
dict comprehensions, there was no need for the backported versions to
replicate this misfeature of 2.x list comprehensions.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to