On 2/24/2015 8:56 PM, Gregory P. Smith wrote:
inspect.getargspec(method) and inspect.signature(method) both include
the 'self' parameter but how are we to figure out from method itself
that it is actually bound and that its first parameter is expected to be
a bound instance?

This seems like a python-list question.

So far I've come up with:
/inspect.ismethod(method) or inspect.ismethoddescriptor(method)/

But that is still not quite right as it remains False in 3.4 for the
simple case of:

 >>> class A:
...  def x(self):
...    pass
...
 >>> inspect.ismethod(A.x)
False
 >>> inspect.ismethoddescriptor(A.x)
False

These are correct. A.x is the function resulting from execution of the def statement.

>>> type(A.x)
<class 'function'>

This is different from 2.x. If you call the function as a function, there is no requirement on its argument, and no binding.

>>> A.x(3)  # returns None
>>>

--
Terry Jan Reedy

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to