[Python-3000] end scope of iteration variables after loop

Nick Coghlan ncoghlan at gmail.com
Sat Apr 19 14:01:44 CEST 2008


Greg Ewing wrote:
> Alex Martelli wrote:
>> LCs were originally designed to leak
> 
> Well, they weren't really *designed* to leak, it was
> just a side effect of the implementation.
> 
> It seems to have been decided that it was better to
> keep it that way than risk breaking things that might
> depend on it. Personally I would rather have had it
> documented as "undefined".

Genexps don't leak their iteration variables, and neither do Py3k list 
comps. So it has only been kept that way in 2.x because nobody came up 
with a graceful way of deprecating it in the past and "list(genexp)" is 
now available as a trivial workaround.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-3000 mailing list