Multiple inheritance - How to call method_x in InheritedBaseB from method_x in InheritedBaseA?

The Music Guy musicguy at alphaios.net
Wed Sep 9 01:47:23 EDT 2009


I should also mention--and I should have realized this much
sooner--that each of the BaseN classes are themselves each going to
have at least one common base which will define method_x, so each
BaseN will be calling that if it defines its own method_x. Again,
sorry I didn't mention that sooner. For some reason it didn't occur to
me that it would be important. I feel dumb now... :P

Here is the updated current example:

class CommonBase(object):
    def method_x(self, a, b c):
        ... no call to superclass' method_x is needed here ...

class MyMixin(object):
   def method_x(self, a, b, c):
       get_other_base(self).method_x(self, a, b, c)
       ...

class BaseA(CommonBase):
   def method_x(self, a, b, c):
       super(BaseA, self).method_x(a, b, c)
       ...

class BaseB(CommonBaset):
   ...

class BaseC(CommonBase):
   def method_x(self, a, b, c):
       super(BaseC, self).method_x(a, b, c)
       ...

class FooX(MyMixin, BaseA):
   ...

class FooY(MyMxin, BaseB):
   ...

class FooZ(MyMixin, BaseC):
   ...



More information about the Python-list mailing list