[Python-Dev] feature request: inspect.isgenerator
Georg Brandl
g.brandl at gmx.net
Thu Jun 1 15:06:31 CEST 2006
More information about the Python-Dev mailing list
Thu Jun 1 15:06:31 CEST 2006
- Previous message: [Python-Dev] feature request: inspect.isgenerator
- Next message: [Python-Dev] feature request: inspect.isgenerator
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Michele Simionato wrote: > Georg Brandl <g.brandl <at> gmx.net> writes: >> >> > Also, should one add >> > a GeneratorType, perhaps as a subclass of FunctionType? >> >> Add GeneratorType where? There is already one in the types module. > > Yep, this is the crux. types.GeneratorType refers to generator objects, > which in an improper sense are "instances" of a "generator function". > I.e. > > def g(): yield 1 # this is a generator > > go = g() # this is a generator object > > I want isgenerator(g) == True, but isgenerator(go) == False. Ah, ok. But then I would name the function differently, perhaps isgeneratorfunc(). > So, what should be the class of g ? Maybe we can keep FunctionType > and don't bother. I would say, keep FunctionType. There's no real need to know the exact type except for inspecting, and for that, the new function in inspect can be used. Georg
- Previous message: [Python-Dev] feature request: inspect.isgenerator
- Next message: [Python-Dev] feature request: inspect.isgenerator
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list