
Predict
Who Answers the Call?
Polymorphism means "many shapes": different classes can answer the
same method call in their own way. Watch what self really is here.
class Spirit:
def greet(self):
return "..."
def visit(self):
return self.greet() + "!"
class Sprite(Spirit):
def greet(self):
return "Hi"
class Wisp(Spirit):
pass
print(Sprite().visit(), Wisp().visit(), Spirit().visit())