[Python-Dev] PEP 289 - Generator Expressions - Let's Move Forward

Guido van Rossum guido at python.org
Mon May 3 13:14:04 EDT 2004


> The problem I have with late-bound names is that small,
> semi-advanced, "innocent enough" examples like Samuele's keep
> popping up that would just give wrong answers (not just crash).

Hm.  I don't think I've seen a single example that wasn't specifically
concocted by early-binding advocates (yours included -- you took
random listcomps and mused on what would happen if they'd be genexprs
instead).

> Personally when I look at all these examples I think they are
> elegant ways to express things that I could want to do, and I could
> easily read and write this kind of code -- but it just doesn't do
> that I expect it to.  The real answer is much more convoluted.

Remember that your brain is several times larger than that of most
Python users.

> The only advantage I see to late binding is that they prevent people
> from doing any advanced stuff with genexprs, and thus beginners
> never have to read code containing advanced uses of genexprs (even
> clean-looking one like Samuele's).

My problem with early binding is that it intruduces a new set of
behind-the-scenes semantics that you cannot always ignore -- while the
examples where it doesn't DWYM are even more obscure than the examples
that it is intended to save, it means that you still have to think
about the new semantics when doing advanced stuff -- and these new
semantics are unlike anything seen before in Python: transformations
that require a definition of "free variables" are not seen anywhere
else (nested scopes use a different concept).

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-Dev mailing list