TypeError: bar() got multiple values for keyword argument '_old'
<p>I know there's a thing called <code>decorator</code> in python, which can do the job more neatly than the following code. But I'm just curious why the following code doesn't work.</p>

<pre><code>#!/usr/bin/env python
# -*- coding: utf-8 -*-

def wrap(old, new):
    "Override an existing function."
    def repl(*args, **kwargs):
        return new(_old=old, *args, **kwargs)
    return repl

class MyClass(object):

    def foo(self, data):
        print data
        return data

def bar(self, _old, data):
    print 'running foo'
    _old(data)
    print 'foo completed'

MyClass.foo = wrap(MyClass.foo, bar)

mc = MyClass()
mc.foo('Test Data')
</code></pre>

<p>When I ran the code, I got an error:</p>

<pre><code>Traceback (most recent call last):
  File "./test.py", line 24, in &lt;module&gt;
    mc.foo('Test Data')
  File "./test.py", line 7, in repl
    return new(_old=old, *args, **kwargs)
TypeError: bar() got multiple values for keyword argument '_old'
</code></pre>

<p>What's wrong here? How can I fix it?</p>