我希望使用Exception.__init__模块获得inspect的签名,但是在inspect类型上使用inspect模块(如Exception和None )会失败,出现以下错误。
/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中定义的内置函数的签名。
发布于 2018-08-03 05:12:19
在Python2.7中,inspect不工作于用C实现的函数或类,因为它们没有inspect获取详细信息所必需的对象属性。
在Python3.x中已经修复了这个问题。
https://stackoverflow.com/questions/51665571
复制相似问题