[Python-projects] PyLint: scope of variable of list comprehension
Maarten ter Huurne
maarten.ter.huurne at philips.com
Wed Jul 19 20:41:39 CEST 2006
Hi,
If I run PyLint on this program:
===
l = [n for n in range(10)]
def f():
n = 2
return n
===
It says:
===
W0621: 3:f: Redefining name 'n' from outer scope (line 1)
===
The same happens if I use a generator expression, like this:
===
l = list(n for n in range(10))
===
But if I run this code in Python, there is no variable named "n" in the
global scope. So it seems that in this respect, the "for" of a list
comprehension / generator expression is different than the "for"
statement.
Bye,
Maarten
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.logilab.org/pipermail/python-projects/attachments/20060719/856b3225/attachment.htm
More information about the Python-Projects
mailing list