Call a function with argument list in python -
I am trying to call function inside a function in Python, but the correct syntax can not be found. What I want to do is something like:
def wrapper (func, args): func (args) def func1 (x): print (x) def func2 (x, y, z) In this case, the first call will work, and the second will be 'back' x + y + z cover (func1, [x]) wrapper (func2, [x, y, z]) T. What I want to modify, is the wrapper function and not the function.
Other answers to make a little more detail on this:
In this line:
Diff wrapper (funk, * args): args means the other parameters given Take it and put them in a list called args ".
In this line:
func (* args) here next to args It means "this list is called algae and in the rest of the parameter it is called 'open'.
Then you can do the following:
def wrapper1 (func , * Args): Def Cover 2 (function, alg) with # starfunk (* args): #StarFunk (* args) DF Funkk 2 (X, Y, Z): Print X + Y + Z Cover Cover 1 (Throw 2, 1, 2, 3) wrapper2 (func2, [1, 2, 3]) in wrapper2 , list Has been clearly passed, but both wrappers have args list [1,2,3] .
Comments
Post a Comment