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

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -