我想使用inspect
模块获取Exception.__init__
的签名,但是在像Exception
和None
这样的Python类型上使用inspect
模块失败,错误如下。你知道吗
/usr/lib/python2.7/inspect.pyc in getargspec(func)
814 func = func.im_func
815 if not isfunction(func):
--> 816 raise TypeError('{!r} is not a Python function'.format(func))
817 args, varargs, varkw = getargs(func.func_code)
818 return ArgSpec(args, varargs, varkw, func.func_defaults)
TypeError: <method-wrapper '__init__' of NoneType object at 0x8ff8d0>
is not a Python function
我想知道如何获得Python中定义类型的内置函数的签名。你知道吗
在python2.7中,
inspect
不适用于用C实现的函数或类,因为它们没有inspect
从中获取详细信息所必需的对象属性。你知道吗在python3.x中已经修复了这个问题
相关问题 更多 >
编程相关推荐