Comprehensions show unusual interactions with scoping. Is this the expected behavior?
x = "original value"
squares = [x**2 for x in range(5)]
print(x) # Prints 4 in Python 2!
At the risk of whining, this is a brutal source of errors. As I write new code, I just occasionally find very weird errors due to rebinding -- even now that I know it's a problem. I need to make a rule like "always preface temp vars in list comprehensions with underscore", but even that's not foolproof. The fact that there's this random time-bomb waiting kind of negates all the nice "ease of use" of list comprehensions.
for
-loop construct andfor
-loops leak variables. So it wasn't explicit but was implicitly stated. – Consign