功能比方说,我有功能仅传递一个变量在Python
def f(x,y):
return x+y
,我想创建一个返回在一个特定的变量传递函数的函数:
def G(f,n,q): #a function in which the n-th variable of function f is passed the value q
return ??
现在的问题是:我应该如何定义G
?
例如,G(f,0,1)
应返回变量0传递值为1的函数f
。换句话说,G(f,0,1)
应该表现为g
,我通过
def g(x):
return f(1,x)
应该为'G(f,1,2)'返回一个'def g(x)'的函数:return f(x,2)'? –
@MosesKoledoye:我认为他的意思是*索引* 0的变量。 –
确实威廉,这就是我的意思。 – user1162809