PEP 255: Simple Generators

Greg Ewing greg at cosc.canterbury.ac.nz
Mon Jun 25 21:39:00 EDT 2001


Andrew Dalke wrote:
> 
> Chemist: A what?  What's a generator?
> Me: It's a function that returns a special kind of object.

You shouldn't have said "function", you should
have said "callable object".

> Me: Well, you can think of a class as a function that returns
>   a special kind of object.

You're going way too fast for this guy, given that
he doesn't know about OO yet. He needs to become
comfortable with OO concepts first, then you can
explain iterator objects, *then* you can explain
what generators do.

Until then, generators are going to seem like
black magic no matter what keyword they're defined
with.

-- 
Greg Ewing, Computer Science Dept, University of Canterbury,	  
Christchurch, New Zealand
To get my email address, please visit my web page:	  
http://www.cosc.canterbury.ac.nz/~greg



More information about the Python-list mailing list