[Python-ideas] type.__signature__ (and Argument Clinic)
ericsnowcurrently at gmail.com
Fri Mar 29 05:26:53 CET 2013
We now have a useful function signature abstraction in 3.3 with PEP
362. An outgrowth of this has been Larry Hasting's efforts on
Argument Clinic. One open question is (was?) how to give a docstring
to the C versions of __new__ and __init__.
Though in the morning I may wonder what I was thinking, here's a
possibility that popped into my head: let classes have a __signature__
attribute that is the signature for meta.__call__, as well as
cls.__new__ and cls.__init__. This makes sense since the three
methods are, together, the default factory for instances of the type.
One would expect them to have the same signature. Keeping that
signature on the class parallels how it is kept on function objects
(rather than on func.__call__).
More information about the Python-ideas