2012-06-06 9 views
7

組み込みメソッドのシグネチャを取得するにはどうすればよいですか? 例:dictの()(k)は組み込みメソッドのシグネチャを取得する - Python

>> 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) 
+0

[ビルドインPythonクラスのコンストラクタの引数リストを取得する方法](http://stackoverflow.com/questions/7628081/how-to-get-arguments-list-of-a-built -in-python-class-constructor) – ChristopheD

+0

関連:http://bugs.python.org/issue1748064短い要約:現時点で(CPythonでは)できません。 – ChristopheD

答えて

4

のような結果を見たいのですが、私はこれはPythonで組み込み関数のための可能性であるとは思いません詳細は、thisバグの解説を参照してください。

関連する問題