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/065522.html below:

[Python-Dev] feature request: inspect.isgenerator

[Python-Dev] feature request: inspect.isgenerator [Python-Dev] feature request: inspect.isgeneratorMichael Chermside mcherm at mcherm.com
Thu Jun 1 19:18:49 CEST 2006
Phillip J. Eby writes:
> Yes, I think the whole concept of inspecting for this is broken.   
> *Any* function can return a generator-iterator.  A generator  
> function is just a function that happens to always return one.

Just following up on Phillip's comments, consider the following functions:


     def foo(x):
         while still_going(x):
            yield some_func(x)

     def bar(x):
         while still_going(x):
             yield other_func(x)

     def foo_or_bar(x):
         if some_condition(x):
             return foo(x)
         else:
             return bar(x)

I presume that Michele's proposal is that inspect.isgenerator() (or
perhaps "inspect.isgenfunc()") would return True for "foo" and "bar"
but false for "foo_or_bar". Can you give a single use case for which
that distinction is desirable?

-- Michael Chermside

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