[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):
>>
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
> 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__[
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
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
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
>> 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
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
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):
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):
>
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
11 matches
Mail list logo