[Python-Dev] feature request: inspect.isgenerator (original) (raw)

Michele Simionato michele.simionato at gmail.com
Thu Jun 1 11:26:15 CEST 2006


Terry Reedy <tjreedy udel.edu> writes:

To me, another obvious way is isinstance(object, gentype) where gentype = type(i for i in []) # for instance which should also be in types module.

No, that check would match generator objects, not generators tout court. On a related notes, inspect.isfunction gives True on a generator, such as

def g(): yield None

This could confuse people, however I am inclined to leave things as they are. Any thoughts?

 Michele Simionato


More information about the Python-Dev mailing list