[Python-Dev] List comprehensions
Raymond Hettinger
python@rcn.com
Wed, 26 Jun 2002 16:48:23 -0400
From: "Gerald S. Williams" <gsw@agere.com>
> I don't want to rehash any old discussions, but I came across a surprise
> recently while converting constructs like "map(lambda x:x+1,x)" and just
> wanted to see the rationale behind not creating a local scope for list
> comprehension variables.
The idea was to make a = [expr(i) for i in seqn]; print i behave the same
as:
a = []
for i in seqn:
a.append(expr(i))
print i # i is in locals in its final loop state
Raymond Hettinger