モジュールから取得したメソッドの引数を調べようとしています。 便利な機能を持つinspect
モジュール、getargspec
が見つかりました。 私は定義した関数に対しては動作しますが、インポートされたモジュールの関数に対しては機能しません。組み込み関数を持つPython inspect.getargspec
import math, inspect
def foobar(a,b=11): pass
inspect.getargspec(foobar) # this works
inspect.getargspec(math.sin) # this doesn't
私はこのようなエラーが得られます。
File "C:\...\Python 2.5\Lib\inspect.py", line 743, in getargspec
raise TypeError('arg is not a Python function')
TypeError: arg is not a Python function
ですinspect.getargspec
ローカルのみの機能のために設計されたのか、私が何か間違ったことをやっていますか?
はい、このように設計されています。http://bugs.python.org/issue1748064 – georg