Re: Dispatch with multiple inheritance

2006-07-19 Thread Michael J. Fromberger
In article <[EMAIL PROTECTED]>, Michael Spencer <[EMAIL PROTECTED]> wrote: > As others have pointed out, super, is designed to do something different from > what you want. See > http://www.python.org/download/releases/2.2.3/descrintro/#cooperation for > GvR's > explanation of super's inten

Re: Dispatch with multiple inheritance

2006-07-19 Thread Michael Spencer
Michael J. Fromberger wrote: ... > > 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. As others have pointed out, super, is designe

Re: Dispatch with multiple inheritance

2006-07-19 Thread Michael J. Fromberger
In article <[EMAIL PROTECTED]>, "Nick Vatamaniuc" <[EMAIL PROTECTED]> 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 supe

Re: Dispatch with multiple inheritance

2006-07-19 Thread Michael J. Fromberger
In article <[EMAIL PROTECTED]>, "Michele Simionato" <[EMAIL PROTECTED]> wrote: > Michael J. Fromberger ha scritto: > > > Consider the following class hierarchy in Python: > > > > > Is there a better (i.e., more elegant) way to handle the case marked > > (**) above? > > > > Curious, > > -M > >

Re: Dispatch with multiple inheritance

2006-07-19 Thread looping
looping wrote: > Michael J. Fromberger wrote: > > > > Is there a better (i.e., more elegant) way to handle the case marked > > (**) above? > > > > You have to call super in each method __init__, if you don't, the call > chain break before the end: > > class A (object): > def __init__(self): >

Re: Dispatch with multiple inheritance

2006-07-18 Thread looping
Michael J. Fromberger wrote: > > Is there a better (i.e., more elegant) way to handle the case marked > (**) above? > You have to call super in each method __init__, if you don't, the call chain break before the end: class A (object): def __init__(self): super(A, self).__init__()

Re: Dispatch with multiple inheritance

2006-07-18 Thread Michele Simionato
Michael J. Fromberger ha scritto: > Consider the following class hierarchy in Python: > > 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.e

Re: Dispatch with multiple inheritance

2006-07-18 Thread Nick Vatamaniuc
Michael, You only need to call the __init__ method of the superclass if you need to do something special during initialization. In general I just use the SuperClass.__init__(self,...) way of calling the super class constructors. This way, I only initialize the immediate parents and they will in tur

Dispatch with multiple inheritance

2006-07-18 Thread Michael J. Fromberger
Consider the following class hierarchy in Python: class A (object): def __init__(self): print "cons A" class B (object): def __init__(self): print "cons B" class C (A): def __init__(self): super(C, self).__init__() print "cons C" class D (B): def