Zen of Python

Paul Rubin http
Fri Jan 21 23:32:46 EST 2005


Tim Peters <tim.peters at gmail.com> 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.



More information about the Python-list mailing list