Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/311.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
Python:如何获取lambda中列表中的参数名称?_Python_Lambda - Fatal编程技术网

Python:如何获取lambda中列表中的参数名称?

Python:如何获取lambda中列表中的参数名称?,python,lambda,Python,Lambda,我应该在有x的地方放置什么,如何在lambda中使用*args和**kwargs?可能吗?不可能。最好的解决方案是使用带有*args和可能的**kwargs的函数: lambda xxxx: a/b argsneeded = ['foo', 'bar'] def whatever(**kwargs): if not all(x in kwargs for x in argsneeded): raise ValueError('required kwarg is miss

我应该在有x的地方放置什么,如何在lambda中使用
*args
**kwargs
?可能吗?

不可能。最好的解决方案是使用带有
*args
和可能的
**kwargs
的函数:

lambda xxxx: a/b
argsneeded = ['foo', 'bar']
def whatever(**kwargs):
    if not all(x in kwargs for x in argsneeded):
        raise ValueError('required kwarg is missing')