How do I say "two classes up in the inheritance chain" in python?

Duncan Booth duncan.booth at invalid.invalid
Tue Jan 27 03:43:38 EST 2009


Daniel Fetchinson <fetchinson at googlemail.com> 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 go ahead and ignore 
it. Only use super if you want to respect your parents. :)

-- 
Duncan Booth http://kupuguy.blogspot.com



More information about the Python-list mailing list