isgenerator(...) - anywhere to be found?

james.pye at gmail.com james.pye at gmail.com
Tue Jan 22 11:14:13 EST 2008


On Jan 22, 6:20 am, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
> For a simple greenlet/tasklet/microthreading experiment I found myself in
> the need to ask the question
>
> isgenerator(v)
>
> but didn't find any implementation in the usual suspects - builtins or
> inspect.

types.GeneratorType exists in newer Pythons, but I'd suggest just
checking for a send method. ;)
That way, you can use something that emulates the interface without
being forced to use a generator.

hasattr(ob, 'send')..



More information about the Python-list mailing list