it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and
Greg Ewing
greg.ewing at canterbury.ac.nz
Mon Feb 27 07:41:07 EST 2023
On 27/02/23 10:07 pm, Roel Schroeven wrote:
> I'm guessing you're thinking about variables leaking out of list
> comprehensions. I seem to remember (but I could be wrong) it was a
> design mistake rather than a bug in the code, but in any case it's been
> fixed now (in the 2 to 3 transition, I think).
The semantics of list comprehensions was originally defined
in terms of nested for loops. A consequence was that the loop
variables ended up in the local scope just as with ordinary for
loops. Later it was decided to change that.
--
Greg
More information about the Python-list
mailing list