Python list comprehension leaks variables
At the last Free Thursday someone told me that Python list comprehensions leak variables. I didn't believe it, but after testing it quickly, it turns out to be true:
foo = [1, 2, 3] bar = [x+1 for x in foo] print x
The above prints out "3". I would have expected it to give a NameError exception.
This turns out to be a known, and deprecated feature in Python 2.5 (see the reference manual), and it will probably be fixed in Python 3000, some time in the future.