class Animal(object):
def __init__(self, name):
self.name = name
def intro(self):
return "I am an animal named %s" %self.name
class Dog(Animal):
def intro(self):
return "I am a dog named %s" %self.name
class Puppy(Dog):
def intro(self):
return "I am a puppy named %s" %self.name
dizzy = Puppy("Dizzy")
What would I do if I wanted a single instance of dizzy.intro() to return the Dog or the Animal intro
method? i.e., I don't want to do a super call within the class to override the method, but I want just a one-off way to specify which of the three intro
methods I'm using on this specific instance of dizzy
?