How do I get the constructor signature for built-in types?

Terry Reedy tjreedy at udel.edu
Tue Jun 5 05:41:14 EDT 2012


On 6/5/2012 1:19 AM, Steven D'Aprano wrote:
> The inspect.getargspec and getfullargspec functions allow you to extract
> the function call signature for Python functions and methods. This allows
> you to work out the constructor signature for pure-Python classes, by
> calling inspect.getargspec on the __init__ or __new__ method.
...

> So far so good. But if the __init__ method is inherited directly from a
> built-in, getargspec fails:

> How do I programmatically get the argument spec of built-in types'
> __init__ or __new__ methods?

Idle tooltips rely on doc strings for builtins. (And by the way, thanks 
for the example, as it might crash Idle even after my current patch. I 
will have to check. See http://bugs.python.org/issue12510 if interested.)

-- 
Terry Jan Reedy




More information about the Python-list mailing list