On Mon, Jul 5, 2010 at 11:12 PM, Tim Golden <mail at 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 | ncoghlan at gmail.com | Brisbane, Australia
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4