Named optional argument and multiple argument order
<p>I have a function wrapper like this. </p>

<pre><code>def funcWrapper(fn_ng, order=None, *args ):
    def clsr(X):
        if order is not None:
            X = calc_poli_dsX(X, order)
        return fn_ng(X, *args);
    return clsr;
</code></pre>

<p>However, if I use this function as below:</p>

<pre><code>mGrdnt = funcWrapper( gd.squared_error, dsX1, dy, order=None)
mGrdnt = funcWrapper( gd.squared_error, dsX1, dy)
</code></pre>

<p>I have error of</p>

<pre><code> TypeError: funcWrapper() got multiple values for keyword argument 'order' 
</code></pre>

<p>My guess was that, if I do not specify 'order', funcWrapper will pass 'dsX1' and 'dy' are passed as *arg, but it turned out they are not. No matter I specify an optional argument, it seems that 'dsX1' and 'dy' all go into the 'order' named optional argument.</p>

<p>How can I make a function wrapper that can pass dsX1 and dy into *arg when the optional argument is/or is not specified?</p>

<p>You can just modify the call:</p>

<pre><code>arr = [dsX1, dy]
funcWrapper(gd.squared_error, None, *arr)
</code></pre>

<p>or you can do something like this: </p>

<pre><code>funcWrapper(gd.squared_error, [dsX1, dy])
</code></pre>

python closures