title: Can you list the keyword arguments a function receives?
body: <p>I have a dict, which I need to pass key/values as keyword arguments.. For example..</p>
  
  <pre><code>d_args = {'kw1': 'value1', 'kw2': 'value2'}
  example(**d_args)
  </code></pre>
  
  <p>This works fine, <em>but</em> if there are values in the d_args dict that are not accepted by the <code>example</code> function, it obviously dies.. Say, if the example function is defined as <code>def example(kw2):</code></p>
  
  <p>This is a problem since I don't control either the generation of the <code>d_args</code>, or the <code>example</code> function.. They both come from external modules, and <code>example</code> only accepts some of the keyword-arguments from the dict..</p>
  
  <p>Ideally I would just do</p>
  
  <pre><code>parsed_kwargs = feedparser.parse(the_url)
  valid_kwargs = get_valid_kwargs(parsed_kwargs, valid_for = PyRSS2Gen.RSS2)
  PyRSS2Gen.RSS2(**valid_kwargs)
  </code></pre>
  
  <p>I will probably just filter the dict, from a list of valid keyword-arguments, but I was wondering: <strong>Is there a way to programatically list the keyword arguments the a specific function takes?</strong></p>