Re: trouble understanding super()

2006-07-31 Thread John Salerno
Duncan Booth wrote: > John Salerno wrote: > >> But after super(D, self).met() is called, doesn't that then call both >> super(B, self).met() and super(C, self).met()? If so, how does that >> avoid calling A.met twice? Or is that not what's happening? > > If you have an instance of a B then supe

Re: trouble understanding super()

2006-07-31 Thread Duncan Booth
John Salerno wrote: > But after super(D, self).met() is called, doesn't that then call both > super(B, self).met() and super(C, self).met()? If so, how does that > avoid calling A.met twice? Or is that not what's happening? If you have an instance of a B then super(B,self).met() will call A.met

Re: trouble understanding super()

2006-07-31 Thread John Salerno
Simon Forman wrote: > In this case the object's (instance of D) mro will be (D, B, C, A, > object), so as super gets called in each class, it looks in that list > (tuple, whatever) for the class following it (actually the next class > following it that implements the method). > > Since no class a

Re: trouble understanding super()

2006-07-31 Thread Simon Forman
John Salerno wrote: > Here's some code from Python in a Nutshell. The comments are lines from > a previous example that the calls to super replace in the new example: > > class A(object): > def met(self): > print 'A.met' > > class B(A): > def met(self): > print 'B.met' >

trouble understanding super()

2006-07-31 Thread John Salerno
Here's some code from Python in a Nutshell. The comments are lines from a previous example that the calls to super replace in the new example: class A(object): def met(self): print 'A.met' class B(A): def met(self): print 'B.met' # A.met(self) super(