introspection question: get return type
bearophileHUGS at lycos.com
bearophileHUGS at lycos.com
Thu May 14 09:02:05 EDT 2009
flam... at gmail.com:
> I am wondering if it's possible to get the return value of a method
> *without* calling it using introspection?
Python is dynamically typed, so you can create a function like this:
>>> foo = lambda x: "x" if x else 1
>>> foo(1)
'x'
>>> foo(0)
1
The return type of foo() changes according to the input value.
In general there's not much hope to know the return type if you don't
actually run the function.
Bye,
bearophile
More information about the Python-list
mailing list