Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/347.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
检查给定的*args和**kwargs是否满足给定的函数签名(python2中的signature.bind())_Python_Python 2.7 - Fatal编程技术网

检查给定的*args和**kwargs是否满足给定的函数签名(python2中的signature.bind())

检查给定的*args和**kwargs是否满足给定的函数签名(python2中的signature.bind()),python,python-2.7,Python,Python 2.7,给定任意函数定义: def f(a, b, *args, kw_a=None, kw_b=123, **kwargs): ... 是否有一种简单的方法可以检查给定的args和kwargs是否满足以下调用: f(*args, **kwargs) 没有实际调用手头的函数 我知道在python3.3及更高版本中有inspect.Signature.bind()。在python2.7中有什么比使用inspect.getargspec()并解析返回的ArgSpec元组更容易的吗?在阅读Vaul

给定任意函数定义:

def f(a, b, *args, kw_a=None, kw_b=123, **kwargs):
    ...
是否有一种简单的方法可以检查给定的
args
kwargs
是否满足以下调用:

f(*args, **kwargs)
没有实际调用手头的函数


我知道在python3.3及更高版本中有
inspect.Signature.bind()
。在python2.7中有什么比使用
inspect.getargspec()
并解析返回的
ArgSpec
元组更容易的吗?

在阅读Vaultah评论中的建议后,我发现python2确实有一个
inspect.signature
的后端口

它叫