Dispatch with multiple inheritance

Michael J. Fromberger Michael.J.Fromberger at Clothing.Dartmouth.EDU
Wed Jul 19 14:59:06 EDT 2006


In article <1153284730.469989.18360 at s13g2000cwa.googlegroups.com>,
 "Michele Simionato" <michele.simionato at gmail.com> wrote:

> Michael J. Fromberger ha scritto:
> 
> > Consider the following class hierarchy in Python:
> > <snip>
> 
> > Is there a better (i.e., more elegant) way to handle the case marked
> > (**) above?
> >
> > Curious,
> > -M
> >
> > --
> > Michael J. Fromberger             | Lecturer, Dept. of Computer Science
> > http://www.dartmouth.edu/~sting/  | Dartmouth College, Hanover, NH, USA
> 
> Look at
> http://www.python.org/download/releases/2.3/mro

Hi, Michele,

I understand what Python's method resolution order is, and how it is 
constructed.  Is there something else in that article, that you hoped 
would address my original concern?  In particular, I am not asking WHY 
super(A, self).__init()__ yields the next method in order -- that is 
quite clear.  Rather, I want to know if there is a better way to invoke 
the ancestry of class E from D, than to explicitly denote the ancestry 
of C in the code.  The latter is an ugly violation of abstraction, and 
renders the class hierarchy brittle.

Of course, I could just bypass super, and explicitly invoke them as:

  C.__init__(self, ...)
  D.__init__(self, ...)

... but that seems to me to defeat the purpose of having super in the 
first place.

It seems as if perhaps there is no better solution at present.  That is 
a pity, albeit a mild one.  Thank you for taking the time to respond.

-M

-- 
Michael J. Fromberger             | Lecturer, Dept. of Computer Science
http://www.dartmouth.edu/~sting/  | Dartmouth College, Hanover, NH, USA



More information about the Python-list mailing list