How to recognize a generator function?
Oscar Rambla
tecnic at codidoc.com
Wed Jun 18 16:20:53 EDT 2003
-Andrew. answered.
>
>How do you know what *any* function returns before you call it?
I'll try to explain me better. Supose :
# a generator-function
def f():
a = 1
yield a
# a kind of callback
def call( object )
if isGeneratorfunction( object):
g = object()
elif Type(object) is GeneratorType:
object.next()
call( f )
The question is the following:
def isGeneratorfunction():
return True
My Original message was:
Hi,
I'm not been able to find a solution to the following:
How to recognize if a function is a generator function before calling it?
(Alternatives to having to inspect code for a yield or wrapping it into a
class).
Note: I refer to the function, not to the generator itself.
Thank you in advance.
-Oscar
-------------------------------------------------------
More information about the Python-list
mailing list