check for valid arguments
<p>So let's define a few functions:</p>

<pre><code>def x(a, b, c): pass
def y(a, b=1, c=2): pass
def z(a=1, b=2, c=3): pass
</code></pre>

<p>Now, what's the best way to, given a pointer to <code>x</code>, <code>y</code>, or <code>z</code> (<code>p</code>), a tuple of args (<code>a</code>) and a dictionary of kwargs (<code>k</code>), check to see if </p>

<pre><code>p(*a, **kw)
</code></pre>

<p>would produce any exception regarding having not enough arguments or incorrect arguments, etc—<em>without</em> actually calling <code>p(*a, **kw)</code> and then catching the exceptions raised.</p>

<h2>Example</h2>

<pre><code>def valid(ptr, args, kwargs): ... #implementation here

valid(x, ("hello", "goodbye", "what?"), {}) # =&gt; True
valid(x, ("hello", "goodbye"), {}) # =&gt; False
valid(y, ("hello", "goodbye", "what?"), {}) # =&gt; True
valid(y, (), {"a": "hello", "b": "goodbye", "c": "what"}) #=&gt; True
valid(y, ("hello", "goodbye"), {"c": "what?"}) #=&gt; True
</code></pre>
