class Thing(object):
def sound(self):
return '' #Silent
class Animal(Thing):
def sound(self):
return 'Roar!'
class MuteAnimal(Animal):
def sound(self):
return '' #Silent
Is there a pattern in python for MuteAnimal
's sound to refer to its grandparent class Thing
's implementation? (eg super(MuteAnimal,self).super(Animal.self).sound()
?) Or is Mixin a better use case here?
As said by Alexander Rossa in Python inheritance - how to call grandparent method? :
Is it sensible to do this?
In
MuteAnimal.sound
, callsuper(Animal, self).sound()
because Animal is in fact, gradparent class of MuteAnimal...