File: class/Workbook/Examples/Lecture7/zoo.py

class Animal:
    def reply(self):   self.speak()
    def speak(self):   print 'spam'

class Mammal(Animal):
    def speak(self):   print 'huh?'

class Cat(Mammal):
    def speak(self):   print 'meow'

class Dog(Mammal):
    def speak(self):   print 'bark'

class Primate(Mammal):
    def speak(self):   print 'Hello world!'

class Hacker(Primate): pass



[Home page] Books Code Blog Python Author Train Find ©M.Lutz