Diez B. Roggisch wrote:

> flam...@gmail.com wrote:
> 
>> Hello,
>> 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:

def foo():
    a = 10

dis.disassemble(foo.func_code)
...
  2           0 LOAD_CONST               0 (None)
              3 RETURN_VALUE
Diez
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to