title: How to replace Python function while supporting all passed in parameters
body: <p>I'm looking for a way to decorate an arbitrary python function, so that an alternate function is called instead of the original, with all parameters passed as a list or dict.</p>
  
  <p>More precisely, something like this (where f is any function, and replacement_f takes a list and a dict):</p>
  
  <pre><code>def replace_func(f, replacement_f):
      def new_f(*args, **kwargs):
          replacement_f(args, kwargs)
      return new_f
  </code></pre>
  
  <p>However, I cannot reference <code>replacement_f</code> inside <code>new_f</code>.  And I can't use the standard trick of passing <code>replacement_f</code> to <code>new_f</code> as the default for a different parameter, because I'm using the <code>*args</code> and <code>**kwargs</code> variable argument lists.</p>
  
  <p>The location where the original function is called cannot change, and will accept both positional and named parameters.</p>
  
  <p>I fear that isn't very clear, but I'm happy to clarify if needed.</p>
  
  <p>Thanks</p>