If I do something with list comprehensions, it writes to a local variable:
i = 0
test = any([i == 2 for i in xrange(10)])
print i
This prints "9". However, if I use a generator, it doesn't write to a local variable:
i = 0
test = any(i == 2 for i in xrange(10))
print i
This prints "0".
Is there any good reason for this difference? Is this a design decision, or just a random byproduct of the way that generators and list comprehensions are implemented? Personally, it would seem better to me if list comprehensions didn't write to local variables.