Help with coroutine-based state machines?
Michele Simionato
mis6 at pitt.edu
Fri May 30 09:40:49 EDT 2003
Alan Kennedy <alanmk at hotmail.com> wrote in message news:<3ED622CA.4B01E3C1 at hotmail.com>...
> But there isn't a generator type in the types module? So, that's a
> question I'd like to ask: can anyone tell me how to discover the
> generator-functions of an object, and differentiate them from
> ordinary functions?
>
Other have answered your question. I will add that *there is* a generator
type in the types module (even if it does not do what you want)
>>> from types import GeneratorType
>>> def g():
... yield 1
>>> type(g()) is GeneratorType
True
Hint: look at the source code of the types module and see how GeneratorType
is defined ...
Michele
More information about the Python-list
mailing list