>> I have two classes that both inherit from two other classes which both
>> inherit from a single class. The two children have two almost
>> identical methods:
>>
>> class grandparent( object ):
>> def meth( self ):
>> # do something
>>
>> class parent1( grandparent ):
>> def meth(
Daniel Fetchinson a écrit :
I have two classes that both inherit from two other classes which both
inherit from a single class. The two children have two almost
identical methods:
class grandparent( object ):
def meth( self ):
# do something
class parent1( grandparent ):
def met
Daniel Fetchinson writes:
> The meth methods in child1 and child2 are the same, except that in
> the last super call, one is referring to parent1, the other is
> referring to parent2.
It's important to learn that, in a language with multiple inheritance,
“superclass of this instance” is *not* th
Daniel Fetchinson wrote:
>
> class child1( parent1 ):
> def meth( self ):
> # do something c
> super( parent1, self ).meth( ) # I want to invoke meth on
> grandparent
So just call:
grandparent.meth(self)
If you want to ignore the inheritance hierarchy then
I have two classes that both inherit from two other classes which both
inherit from a single class. The two children have two almost
identical methods:
class grandparent( object ):
def meth( self ):
# do something
class parent1( grandparent ):
def meth( self ):
# do someth