Dispatch with multiple inheritance

Michael J. Fromberger Michael.J.Fromberger at Clothing.Dartmouth.EDU
Wed Jul 19 15:15:34 EDT 2006


In article <1153252105.248719.147020 at m73g2000cwd.googlegroups.com>,
 "Nick Vatamaniuc" <vatamane at gmail.com> wrote:

> Michael,
> You only need to call the __init__ method of the superclass if you need
> to do something special during initialization. 

Hi, Nick,

Thank you for responding.  I understand the purpose in invoking the 
superclasses' __init__ methods.  Let us take it as a given that I 
require this behaviour; the simple example does not show it, but I am 
using the same technique in a much more elaborate program, where in fact 
the superclass initialization is required.

> In general I just use the SuperClass.__init__(self,...) way of 
> calling the super class constructors.

Yes, and that certainly works just fine.  But it obviates the point of 
having super().  But perhaps that is the take-home message.

I do not want A's constructor to dispatch further along in the MRO for E 
for two reasons:  One, because the constructors along the (E D B) chain 
take different argument lists (in my real code) than the (E C A) path; 
and two, because I happen to care about the order in which the methods 
are invoked.

> In general note that  __init__ is NOT a constuctor it is an initializer

Yes, you're right; I apologize for the imprecision.  However, for the 
purposes of this example, the distinction is irrelevant.

Cheers,
-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