[Python-Dev] Re: PEP 255: Simple Generators
Wed, 20 Jun 2001 18:17:09 +1200
Tim Peters wrote:
> This is like saying that functions returning integers should be declared
> "defint" instead, or some such gibberish.
Not the same thing. If a function returns an integer,
somewhere in it or in something that it calls there
is a piece of code that explicitly creates an
But under PEP 255, there is *nothing* anywhere
in the code that you can point to and say "look,
here is where the generator-iterator is created!"
Instead, it happens implicitly at some point
just after the generator-function is called, but
before any of its code is executed.
You could say that the same thing is true when
you call a class object -- creation of the instance
happens implicitly before __init__ is called.
But there is no secret made of the fact that classes
are not functions, and there is nothing in the syntax
to lead you to believe that they behave like functions.
In contrast, the proposed generator syntax makes
generators look so nearly like functions that their
actual behaviour, once you get your head around it,
seems quite bizarre.
I just think it's going to lead to a lot of confusion
and misunderstanding, among newcomers especially.
Greg Ewing, Computer Science Dept, University of Canterbury,
Christchurch, New Zealand
To get my email address, please visit my web page: