<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
(Quick, because apparently nobody reads the long ones!)<br>
<br>
In Python 3.3:<br>
<blockquote>>>> class C:<br>
... def foo(self, a): pass<br>
... <br>
>>> c = C()<br>
>>> help(c.foo)<br>
</blockquote>
shows you the signature "foo(self, a)". As in, it claims it accepts
two parameters. The function actually only accepts one parameter,
because "self" has already been bound. inspect.signature gets this
right:<br>
<blockquote>>>> import inspect<br>
>>> str(inspect.signature(c.foo))<br>
'(a)'<br>
</blockquote>
but inspect.getfullargspec does not:<br>
<blockquote>>>> inspect.getfullargspec(c.foo)<br>
FullArgSpec(args=['self', 'a'], varargs=None, varkw=None,
defaults=None, kwonlyargs=[], kwonlydefaults=None, annotations={})<br>
</blockquote>
<br>
help() gets its text from pydoc. pydoc uses inspect.getfullargspec
to produce the signature.<br>
<br>
When I added support for introspection on builtins, I wanted help()
to show their signature too. But inspect.getfullargspec doesn't
support introspection on builtins. So I had to use
inspect.signature. Which means the behavior is inconsistent: help()
on a method of an instance of a builtin class *doesn't* show "self".<br>
<br>
<br>
FYI, the relevant issues:<br>
<blockquote>help(instance_of_builtin_class.method) does not display
self<br>
<blockquote><a class="moz-txt-link-freetext" href="http://bugs.python.org/issue20379">http://bugs.python.org/issue20379</a><br>
</blockquote>
inspect.getfullargspec should use __siganture__<br>
<blockquote><a class="moz-txt-link-freetext" href="http://bugs.python.org/issue17481">http://bugs.python.org/issue17481</a><br>
</blockquote>
</blockquote>
<br>
What should it be?<br>
<br>
A) pydoc and help() should not show bound parameters in the
signature, like inspect.signature.<br>
B) pydoc and help() should show bound parameters in the signature,
like inspect.getfullargspec.<br>
<br>
I'll tally the results if there's interest. I'd assume a "vote for
A" = +1 on A and -1 on B. You can express your vote numerically if
you like. I'm voting for A.<br>
<br>
<br>
And yes, that was short for me,<br>
<br>
<br>
<i>/arry</i><br>
</body>
</html>