Call a function with argument list in python. Learn Python at ...
python.engineering › 817087-call-a-function-withdef wrapper1 (func, *args): # with star func (*args) def wrapper2 (func, args): # without star func (*args) def func2 (x, y, z): print x+y+z wrapper1 (func2, 1, 2, 3) wrapper2 (func2, [1, 2, 3]) In wrapper2, the list is passed explicitly, but in both wrappers args contains the list [1,2,3].
Call a function with argument list in python
town-and-cooking.com › call-a-function-withThis tells Python to take the list given (in this case, args) and pass its contents to the function as positional arguments. This trick works on both "sides" of the function call, so a function defined like this: def func2(*args): return sum(args) would be able to accept as many positional arguments as you throw at it, and place them all into a list called args. I hope this helps to clarify things a little.