PEP 255: Simple Generators

David Goodger dgoodger at bigfoot.com
Thu Jun 21 20:50:10 EDT 2001


Generators are very cool. I'm sure I will use them. I'm glad they're getting
into Python. Thank you Neil, Tim, and Magnus, for all your work.

on 2001-06-21 2:57 PM, Tim Peters (tim at digicool.com) wrote:
> a generator-function returns a generator-iterator

That's what it boils down to. Before generators, all functions returned
objects using explicit 'return' statements. Now, generator-functions return
generator-iterators, but there's *nothing* explicitly saying 'return
generator_iterator'. Before generators, calling a function executed its
code. Now, calling a generator-function doesn't execute the code at all; you
have to execute the magically returned object. Only the 'yield' indicates
any of this variant behavior.

Can I get used to it? Yes, I think I have enough spare brain cells. (Heck, I
used to know Perl! ;-)

Should I get used to it?

"Explicit is better than implicit."

-- 
David Goodger    dgoodger at bigfoot.com    Open-source projects:
 - Python Docstring Processing System: http://docstring.sf.net
 - reStructuredText: http://structuredtext.sf.net
 - The Go Tools Project: http://gotools.sf.net




More information about the Python-list mailing list