3 ms·
Python (before version 3) leaks variables from list comprehension, while it seems natural to assume that the comprehension has its own scope. Makes for some fun
by anonymouz 14y ago
Python (before version 3) leaks variables from list comprehension, while it seems natural to assume that the comprehension has its own scope. Makes for some funny bugs:
i = ...
... # lots of code
[ do_stuff(i) for i in range(n) ]
...
# whoops, our outside i has now been modified