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
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
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
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
> >
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):
>
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__()
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
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
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