list comprehensions put non-names into namespaces!

Diez B. Roggisch deets at nospam.web.de
Fri May 26 07:03:56 EDT 2006


Ben Cartwright schrieb:
> skip at pobox.com wrote:
>> Lonnie> List comprehensions appear to store their temporary result in a
>>     Lonnie> variable named "_[1]" (or presumably "_[2]", "_[3]" etc for
>>     Lonnie> nested comprehensions)
>>
>> Known issue.  Fixed in generator comprehensions.  Dunno about plans to fix
>> it in list comprehensions.  I believe at some point in the future they may
>> just go away or become syntactic sugar for a gen comp wrapped in a list()
>> call.
> 
> The latter, starting in Python 3.0.  It won't be fixed before Python
> 3.0 because it has the potential to break existing 2.x code.  From PEP
> 289:

That is a different beast. Lonnie is after the temporary list variables 
created, with otherwise illegal names in python.

Diez



More information about the Python-list mailing list