PEP 255: Simple Generators
paulp at ActiveState.com
Tue Jun 26 21:03:59 CEST 2001
Greg Ewing wrote:
> > 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.
This is a key question. I also would define generators in terms of
methods and iterators. On the other hand, those with the icon mentality
consider that just an implementation artifact. I would teach generators
only to people who understand most of the "rest of Python". Others seem
to want to teach them alongside other flow control keywords. It will be
interesting to see how this shakes out in practice.
Take a recipe. Leave a recipe.
Python Cookbook! http://www.ActiveState.com/pythoncookbook
More information about the Python-list