Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get built in method signature - Python

How do I get the signature of built in methods? Example: dict().get(k)

>> a = dict().get
>> a
<built-in method get of dict object at 0x1003aafd0>
>> a.__doc__
'D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.'
>> import inspect
>> inspect.getargspec(a)
TypeError: <built-in method get of dict object at 0x100377250> is not a Python function

I would like to see the result like this

>> a.some_function()
('key', 'default'=None)
like image 987
Bharad Avatar asked Jun 06 '12 19:06

Bharad


1 Answers

I don't think this is possible for the built-in functions in python that are implemented in C. See this bug discussion for further details.

like image 156
Bobby W Avatar answered Sep 19 '22 04:09

Bobby W