generator function

Skip Montanaro skip at pobox.com
Thu Aug 7 16:38:58 CEST 2003


>>>>> "tom" == tom chansky <tom_chansky at rocketmail.com> writes:

    tom> I read the following link about generator:
    tom> http://www.python.org/peps/pep-0255.html
    tom> but I am still not so clear on the use/purpose of a generator function
    tom> other than the fact that a generator can retain the state of the local
    tom> variables within the fuction body.

That's generally a more than sufficient reason.  Have a look at the
SpamBayes tokenizer module and the several tokenize* methods and functions
it contains for some fairly elaborate examples:

    http://tinyurl.com/jaun

Skip





More information about the Python-list mailing list