How to pass list of function and all its arguments to be executed in another function in python?
<p>I have a list of functions and its arguments like this:</p>

<pre><code>(func1, *arg1), (func2, *arg2),...
</code></pre>

<p>I want to pass them into another function to execute them like this:</p>

<pre><code>for func, arg* in (list of funcs, args):
   func(arg*)
</code></pre>

<p>How to do it in python? I have tried several but it doesn't like unpacking and *arg at the same time.</p>

<p>Assuming your function and arguments are separate in the tuple, </p>

<pre><code>def squarer(*args):
    return map(lambda x: x*2, args)

def subtracter(*args):
    return map(lambda x: x-1, args)

funcAndArgs = [(squarer, [1,2,3,4]), (subtracter, [1,2,3,4])]

for func, args in funcAndArgs:
    print func(*args)
</code></pre>

<p>Output:</p>

<pre><code>[2, 4, 6, 8]
[0, 1, 2, 3]
</code></pre>

python