See exactly what a function has returned
Roy Smith
roy at panix.com
Wed Sep 15 14:03:57 EDT 2004
In article <ci9tfk$71t$1 at solaris.cc.vt.edu>,
Brad Tilley <bradtilley at usa.net> wrote:
> Is there an easier way to do this:
>
> def print_whats_returned(function):
> print function
> print type(function)
In the general case, this is not possible. A function can return
different things at different times. Consider the following function:
def getSomething ():
if random.random () < 0.5:
return 42
else:
return "fourty-two"
so what type would you say this returns?
More information about the Python-list
mailing list