In this tutorial you will learn about the Python Inheritance and its application with practical example.
Python Inheritance
The inheritance is one of the important feature in object oriented programming, that gives you a way to reuse of code. Inheritance is a process through which a classes can inherit properties and methods from other classes, know as super-classes. A class that inherits from super-classes is know as Sub-class or Derived-Class.
Python Single Inheritance
Syntax:-
1 2 3 4 5 |
class BaseClass # Body of base class class DerivedClass(BaseClass): #Body of derived class |
Python Multiple Inheritance
1 2 3 4 5 6 7 8 |
class BaseClass1 # Body of base class class BaseClass2 # Body of base class class DerivedClass(BaseClass1,BaseClass1): #Body of derived class |