Replacing base class

Alexey Klimkin klimkin at mcst.ru
Wed Mar 3 09:35:43 EST 2004


Hello!

Is it possible in python to replace base class with another one?

Assume an example:
class A:
  def f(self):
    print 'A'
class B(A):
  def f(self):
    A.f(self)
    print 'B'
class C:
  def f(self):
    print 'C'

I need to make class Bm with the same functionality as B, but 
derived from C, instead of A. Classes C and A have the same
interface.

The call of f() for Bm should output:
C
B

As you see, the main problem is B.f, since it uses f() from base
class. Any clues?

Regards,
Alexey




More information about the Python-list mailing list