Paul Rubin wrote:
Tim Peters <[EMAIL PROTECTED]> writes:

But at that time, Python didn't have lexical scoping, and it wasn't
clear that it ever would. So what's the bigger wart? Making
listcomps exactly equivalent to an easily-explained Python for-loop
nest, or introducing a notion of lexical scope unique to listcomps,
hard to explain in terms of the way the rest of the language worked?

Oops, I'd gotten confused and thought lexical scope came first and listcomps afterwards. If lexical scope came afterwards, then implementing listcomps as a for-loop at that time makes more sense.

Of course in that case, since the absence of lexical scope was a wart
in its own right, fixing it had to have been on the radar.  So turning
the persistent listcomp loop var into a documented feature, instead of
describing it in the docs as a wart that shouldn't be relied on,
wasn't such a hot idea.  Adding lexical scope and listcomps at the
same time might have also been a good way to solve the issue.

Can we get a show of hands for all of those who have written or are currently maintaining code that uses the leaky listcomp "feature"?


I guess I've been peripherally aware of it, but I almost always use names like "x" for my loop variables, and never refer to them afterwards. If Python were to change in this regard, I don't think it would break any Python code that I've ever written or maintained...

Dave
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to