[Python-Dev] Multiple inheritance (original) (raw)
Paul F. Dubois paul@pfdubois.com
Thu, 3 May 2001 09:24:40 -0700
- Previous message: [Python-Dev] OT: CVS access through firewall via SSH
- Next message: [Python-Dev] Multiple inheritance
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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"):
- 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): self._sfoo() myfoostuff
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.
- Previous message: [Python-Dev] OT: CVS access through firewall via SSH
- Next message: [Python-Dev] Multiple inheritance
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]