generator function

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

>>>>> "tom" == tom chansky <tom_chansky at> writes:

    tom> I read the following link about generator:
    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:


More information about the Python-list mailing list