Re: [Python-Dev] feature request: inspect.isgenerator

2006年6月01日 10:18:58 -0700

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
_______________________________________________
Python-Dev mailing list
[email protected]
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