generator function

Terry Reedy tjreedy at udel.edu
Thu Aug 7 13:06:16 EDT 2003


"chansky" <tom_chansky at rocketmail.com> wrote in message
news:215fa0fc.0308070503.2344dd66 at posting.google.com...
> I read the following link about generator:
> http://www.python.org/peps/pep-0255.html
> but I am still not so clear on the use/purpose of a generator
function
> other than the fact that a generator can retain the state of the
local
> variables within the fuction body.  Can someone out there shed some
> lights on this topic or share about how/when you would ever use a
> generator function.

Besides the other answers, Lib/test/test_generators.py, at 40K,
contains a tutorial and lots of examples, include some that many would
not readily think of.

TJR






More information about the Python-list mailing list