Inheritance in Python

A class can inherit attributes and behaviour methods from another class, called the superclass . A class which inherits from a superclass is called a subclass , also called heir class or child class. Inheritance enable us to define a class that takes all the functionality from parent class and allows us to add more.
class MyBaseClass: #Base class implementations class MyDerivedClass(MyBaseClass): #Derived class implementations
class Animal(object): def makeSound(self): raise NotImplementedError() class Dog(Animal): def makeSound(self): print ("woff!") class Cat(Animal): def makeSound(self): print ("meow")