Inheritance at work (see
Python Inheritance[
^]):
class Animal(object):
def __init__(self, nlegs=4):
self.nlegs = nlegs
class Dog(Animal):
def __init__(self, talk='Bahu Bhau'):
Animal.__init__(self)
self.talk = talk
class Crow(Animal):
def __init__(self, talk='Ka Ka'):
Animal.__init__(self,2)
self.talk = talk
c = Crow()
print(c.talk)
print(c.nlegs)