Possible Duplicate:
Python list comprehension overriding value
I did some googling around, but no solutions to this issue. It seems like list comprehensions mess with the current namespace, which seems really odd to me.
print i
print [i for i in range(10)]
print i
The first is an error, the second prints range(10) as expected, and the last line prints 9, the 'last value of i' for the list comprehension. This is completely unexpected to me. What's more, if i was previously defined, it's now been overwritten.
I'm running on Apple's build of Python 2.7 (OS X Lion), if that means anything.