[Python-Dev] Multiple inheritance

Paul F. Dubois paul@pfdubois.com
Thu, 3 May 2001 09:24:40 -0700

Pardon if this is brief and suggestive only, I am on deadlines.

Super is a mistaken concept in multiple inheritance languages. Fortunately,
Python is not brain-damaged. Its multiple inheritance model can be fixed
easily to be fully capable.

Here is a suggestive example of implementing the Eiffel model (the only one
that is theoretically sound) using "pretend" Python syntax (keyword
conservationists might like "import" where I have "rename"):

1. The simple case, X inherits from Y and in defining foo and bar needs to
use Y's version:

class X (Y rename foo as _sfoo,
                  bar as _sbar
    def foo (self):

Suppose D inherits from B and C, which both inherit from A.
A has a method a1 that is redefined in B but not in C.
D wishes to use both A's version as inherited via C and B's version.

class D (B rename a1 as ba1, C rename a1 as ca1):

     can now use self.ca1, self.a1

Renaming is also useful where you inherit from a utility class and the lingo
is different in the class where you want to use it. E.g. class Window (Tree
rename children as subWindows)

Reference: Meyer, B. "Object-Oriented Software Construction", 2nd Edition.