【发布时间】:2012-06-06 19:04:20
【问题描述】:
如何获得内置方法的签名? 示例: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
我想看到这样的结果
>> a.some_function()
('key', 'default'=None)
【问题讨论】:
-
相关:bugs.python.org/issue1748064 简短摘要:目前(在 CPython 中)你不能。