adding a keyword argument to an overriden method and using **kwarg
<p>I am subclassing an object in order to override a method that I want to add some functionality to. I don't want to completely replace it or add a differently named method but remain compatible to the superclasses method by just adding an optional argument to the method.
Is it possible to work with <code>*args</code> and <code>**kwargs</code> to pass through all arguments to the superclass and still add an optional argument with a default?
I intutively came up with the following but it doesn't work:</p>

<pre><code>class A(object):
    def foo(self, arg1, arg2, argopt1="bar"):
        print arg1, arg2, argopt1

class B(A):
    def foo(self, *args, argopt2="foo", **kwargs):
        print argopt2
        A.foo(self, *args, **kwargs)


b = B()
b.foo("a", "b", argopt2="foo")
</code></pre>

<p>Of course I can get it to work when I explcitly add all the arguments of the method of the superclass:</p>

<pre><code>class B(A):
    def foo(self, arg1, arg2, argopt1="foo", argopt2="bar"):
        print argopt2
        A.foo(self, arg1, arg2, argopt1=argopt1)
</code></pre>

<p>What's the right way to do this, do I have to know and explicitly state all of the overridden methods arguments?</p>
