获取内置方法签名 - Python [英] Get built in method signature - Python
本文介绍了获取内置方法签名 - Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何获得内置方法的签名?
例如:dict()。get(k)
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)
推荐答案
我不认为这可能是在C中实现的内置函数。请参阅这个 bug讨论了解更多细节。
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.
这篇关于获取内置方法签名 - Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文