PEP 318

Greg Ewing (using news.cis.dfn.de) ieyf4fu02 at sneakemail.com
Wed Mar 24 01:15:42 EST 2004


Paul Rubin wrote:
> The syntax can be extended, i.e. "def foo() as generator" looks to me
> to be a lot more explicit than "def foo()" followed by having the
> compiler search the function body for a yield statement in order
> to decide if it's a generator.

While I happen to agree that generators ought to be
created using something other than a plain "def",
it couldn't be done this way. Generators need to be
compiled differently from the beginning -- you can't
turn an ordinary function into a generator by
wrapping it in anything.

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg




More information about the Python-list mailing list