[issue17481] inspect.getfullargspec should use __signature__

Larry Hastings report at bugs.python.org
Sat Jan 25 04:56:06 CET 2014


Larry Hastings added the comment:

There's a major difference between getfullargspec/getargspec and inspect.signature: getfullargspec shows you the "self" parameter for bound methods, and inspect.signature does not.

>>> class C:
...    def foo(self, a):  pass
... 
>>> c = C()
>>>
>>> import inspect
>>> str(inspect.signature(c.foo))
'(a)'
>>> inspect.getfullargspec(c.foo)
FullArgSpec(args=['self', 'a'], varargs=None, varkw=None, defaults=None, kwonlyargs=[], kwonlydefaults=None, annotations={})
>>> inspect.getargspec(c.foo)
ArgSpec(args=['self', 'a'], varargs=None, keywords=None, defaults=None)

This is why help() (currently) shows bound parameters for methods implemented in Python, but doesn't show them for methods implemented in C.  pydoc uses inspect.getfullargspec for pure Python functions and inspect.signature for builtins.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17481>
_______________________________________


More information about the Python-bugs-list mailing list