"Michele Simionato" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Neal Norwitz <nnorwitz <at> gmail.com> writes:
>>
>> > I wonder whether a check shouldn't just return (co_flags & 0x20), 
>> > which
>> > is CO_GENERATOR.
>>
>> Makes more sense.
>
> Okay, but my point is that the final user should not be expected to know
> about those implementation details. The one obvious way to me is to have 
> an
> inspect.isgenerator, analogous to inspect.isfunction, inspect.ismethod, 
> etc.
> The typical use case is in writing a documentation/debugging tool. Now I
> was writing a decorator that needed to discriminate in the case it was
> decorating a regular function versus a generator.

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.

tjr



_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to