title: override recursive method in python
body: <p>When I call the base class recursive method from the derived class, the recursive call is done against the derived method, instead of the base class method. How can I avoid that <strong>without modifying base class implementation</strong> (in example class A)?</p>
  
  <p>Here is an example</p>
  
  <pre><code>class A(object):
      # recursive method
      def f(self, x):
          print x,
          if x &lt; 0:
              self.f(x+1)
          if x &gt; 0:
              self.f(x-1)
          if x == 0:
             print ""
  
  class B(A):
     # Override method 
     def f(self):
         # do some pretty cool stuff
         super(B, self).f(25)
  
  if __name__ == "__main__":
      A().f(5)
      B().f()
  </code></pre>
  
  <p>I've got this output:</p>
  
  <pre><code>5 4 3 2 1 0 
  25
  Traceback (most recent call last):
    File "./test.py", line 19, in &lt;module&gt;
       B().f()
    File "./test.py", line 15, in f
       super(B, self).f(25)
     File "./test.py", line 9, in f
       self.f(x-1)
    TypeError: f() takes exactly 1 argument (2 given)
  </code></pre>
  
  <p>Thanks in advance,</p>