Passing uncertain amount of inputs to one function's sub-functions
<p>Sorry if I did not explain myself clearly.
I would like to create a wrapper to call pre-defined functions with different number of inputs. Of course, I can create an individual wrapper for each function, but I am wondering if there is a way to create a generic wrapper for all cases.</p>

<p>The functions that should be called are named 'fun1' and 'fun2' with different number of inputs. I need to create a wrapper 'fun_wrap(func_name, uncertain amount of inputs)', which only needs the function name to be called and its associated amount of inputs.</p>

<p>One more thing, I need to change the input names by adding '_in' and make them global variables first. Below is my broken code. Thanks for any suggestions!</p>

<pre><code>def fun1(a,b):
    return a+b

def fun2(a,b,c):
    return a*b/c

def set_globals(**kwargs):
    for argname in kwargs:
        globals()['%s_in' % argname] = kwargs[argname]

def fun_wrap(func_name, uncertain amount of inputs):
    ffunc_name(set_globals(uncertain amount of inputs))
</code></pre>

<p>In this way, if I can call final_fun with arguments like:</p>

<pre><code>fun_wrap(fun1,a,b)
fun_wrap(fun2,a,b)
</code></pre>

UPDATE

<p>I tried to use *arg, but failed...</p>

<pre><code>def fun1(a,b):
    return a+b

def fun2(a,b,c):
    return a*b/c

def set_globals(**kwargs):
    for argname in kwargs:
        globals()['%s_in' % argname] = kwargs[argname]

def fun_wrap(func_name, *arg):
    func_name(set_globals(*arg))

fun_wrap(fun2,a=1,b=2,c=3)
</code></pre>

<p>got error:</p>

<pre><code>Traceback (most recent call last):
  File "D:\Dropbox\AppPest\rice\try.py", line 19, in &lt;module&gt;
    fun_wrap(fun2,a=1,b=2,c=3)
TypeError: fun_wrap() got an unexpected keyword argument 'a'
</code></pre>
