A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-June/065510.html below:

[Python-Dev] feature request: inspect.isgenerator

[Python-Dev] feature request: inspect.isgenerator [Python-Dev] feature request: inspect.isgeneratorTerry Reedy tjreedy at udel.edu
Thu Jun 1 10:50:27 CEST 2006
"Michele Simionato" <michele.simionato at gmail.com> wrote in message 
news:loom.20060601T090603-423 at post.gmane.org...
> 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



More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4