introspection question: get return type
Diez B. Roggisch
deets at nospam.web.de
Thu May 14 15:07:24 CEST 2009
Diez B. Roggisch wrote:
> flamz3d at gmail.com wrote:
>> I am wondering if it's possible to get the return value of a method
>> *without* calling it using introspection?
> Nope. All that's possible to see if there is a implicit or explicit return
> through dis.disassemble - if you find "LOAD_CONST None" before any
> return-statement, you know that you don't anything else.
Gosh, this is barely intelligible...
What I wanted to say is that you can check if a function only returns
constant values, which most of the time will be implicit "return None"
statements, as in this:
a = 10
2 0 LOAD_CONST 0 (None)
More information about the Python-list