Re: grandparent method with super

2007-04-05 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > On Apr 5, 3:19 pm, Martin Manns <[EMAIL PROTECTED]> wrote: > >>Hi, >> >>I have a class structure as follows and I would like to invoke the >>method A.m() from D.m >> >>class A(object): >>def m(self): >>class B(A): >>def m(self): >>class C(A): >>

Re: grandparent method with super

2007-04-05 Thread Martin Manns
On 5 Apr 2007 15:05:25 -0700 [EMAIL PROTECTED] wrote: > > class E(C,D): > def m(self): > for cls in E.__mro__: > if cls != E and cls not in E.__bases__: > cls.m(self) > break > > > ... but it's probably better that you > rethink your class

RE: grandparent method with super

2007-04-05 Thread John Clark
> Not really. The first grandparent would be the first occurrence in the list from left to right, which satisfies the requirement that its shortest path to the current class is 2. > The only problem: How do I get it? > Martin I suppose you could do a self.__class__.__bases__[0].__bases__[

Re: grandparent method with super

2007-04-05 Thread attn . steven . kuo
On Apr 5, 2:13 pm, Martin Manns <[EMAIL PROTECTED]> wrote: > On Thu, 5 Apr 2007 16:55:38 -0400 > > > > "John Clark" <[EMAIL PROTECTED]> wrote: > > >That works, but when I replace A with something else, I do not get > > >the > > grandparent anymore > > >without changing all the method calls. Basical

Re: grandparent method with super

2007-04-05 Thread Gabriel Genellina
En Thu, 05 Apr 2007 18:13:06 -0300, Martin Manns <[EMAIL PROTECTED]> escribió: > On Thu, 5 Apr 2007 16:55:38 -0400 > "John Clark" <[EMAIL PROTECTED]> wrote: >> Because the MRO isn't just a depth first traversal, the term "first >> grandparent" gets tricky to define... > > Not really. The first gr

Re: grandparent method with super

2007-04-05 Thread Martin Manns
On Thu, 5 Apr 2007 16:55:38 -0400 "John Clark" <[EMAIL PROTECTED]> wrote: > >That works, but when I replace A with something else, I do not get > >the > grandparent anymore > >without changing all the method calls. Basically, I would like to > >call the > method m in the first > >grandpar

RE: grandparent method with super

2007-04-05 Thread John Clark
>> Pretty sure you can do this: >> >> class A(object): >> def m(self): >> class B(A): >> def m(self): >> class C(A): >> def m(self): >> class D(B,C): >> def m(self): >> A.m(self) >> >> I don't think you want to try to use super() in this case. > >That works, but

Re: grandparent method with super

2007-04-05 Thread Martin Manns
On Thu, 5 Apr 2007 16:33:37 -0400 "John Clark" <[EMAIL PROTECTED]> wrote: > Pretty sure you can do this: > > class A(object): > def m(self): > class B(A): > def m(self): > class C(A): > def m(self): > class D(B,C): > def m(self): > A.m(self) > > I don't thi

RE: grandparent method with super

2007-04-05 Thread John Clark
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Martin Manns Sent: Thursday, April 05, 2007 4:20 PM To: python-list@python.org Subject: grandparent method with super Hi, I have a class structure as follows and I would like to invoke the method A.m() from D.m class A(object):

Re: grandparent method with super

2007-04-05 Thread kyosohma
On Apr 5, 3:19 pm, Martin Manns <[EMAIL PROTECTED]> wrote: > Hi, > > I have a class structure as follows and I would like to invoke the > method A.m() from D.m > > class A(object): > def m(self): > class B(A): > def m(self): > class C(A): > def m(self): > class D(B,C): >

grandparent method with super

2007-04-05 Thread Martin Manns
Hi, I have a class structure as follows and I would like to invoke the method A.m() from D.m class A(object): def m(self): class B(A): def m(self): class C(A): def m(self): class D(B,C): def m(self): # Call A.m with super? I have read http://www.py