Pass kwargs with invalid key=value pairs to function
<p>The following code:</p>

<pre><code>def f(a=1):
    pass

kwargs = {}
kwargs['a'] = 1
kwargs['b'] = 2

f(**kwargs)
</code></pre>

<p>(correctly) raises an Exception:</p>

<pre><code>Traceback (most recent call last):
  File "tt.py", line 8, in &lt;module&gt;
    f(**kwargs)
TypeError: f() got an unexpected keyword argument 'b'
</code></pre>

<p>Is there a way, with functools or other, to get around this and figure out which arguments didn't get used by the function in order to be able to pass them to another function? For example, I might have another function:</p>

<pre><code>def g(a=None, b=None):
    pass
</code></pre>

<p>which I want to call after, with e.g.</p>

<pre><code>g(**kwargs)
</code></pre>

<p>but I only want <code>b</code> to be passed because <code>a</code> was already 'used up' in the previous function.</p>

<p>Now I know that this is not ideal coding, but there are cases where it can come in handy, and it is actually easy to explain to the user, e.g. "Additional parameters will be passed to f, and any parameters not passed to f will be passed to g".</p>
