On 9/22/05, Greg Ewing <[EMAIL PROTECTED]> wrote: > Josiah Carlson wrote: > > > As for list comprehensions, they were literally meant to be a > > completely equivalent translation of a set of for loops. > > I don't think that's quite true. I doubt whether anyone > really thought about the issue when LCs were first being > discussed. I didn't, but if I had, I wouldn't have > considered the variable-leaking as being something that > it was necessary to preserve, because the only use case > for it is something you can't do with an LC anyway. > > The reasons for the variable-leaking being preserved are > (1) it fell out of the implementation and (2) it makes the > documentation slightly simpler, since LCs can be described > fully and accurately in terms of translation to for-loops. > > Whether those are *good* reasons or not is debatable.
It was the cheapest implementation; it was known at the time that it wasn't ideal. I'd like to fix this in 3.0, so that LC's are just a special case of GE's. > In Py3k it's possible that this will be resolved by making > for-loop variables local to the loop as well. Or maybe not. Definitely not. There are lots of uses for the loop control variable after break. -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com