Inheritance in Python
Inheritance is one of the very important basic principles of object-oriented programming. The concept is that we are going to create a new class, using an existing class. This helps much in terms of code reusability and helps in thinking in terms of real-world problems. Let’s understand the concept of inheritance with some real-world examples. Let’s consider that there is some child, who sings well, and his/her mother also sings well. In such situations, we say that the child has got the quality of singing from his/her mother.
Let’s now try to relate it to the programming. We have said above that here, we are going to create another class, using the existing class. So here, there are different terminologies that we need to understand, like the base class, and derived class. So, Let’s have a look at those terminologies now.
As the definition says, we are going to create another class, from an already existing class, so, the class from which we are going to create another class, or we can say that the class that is going to be inherited, is called the parent class, or the base class, or the super class. On the other hand, the class that is going to be created from another class, or we can say that the class that is going to inherit the methods and attributes from the parent class, is called the derived class, the child class, or the sub class.
Soon, we are going to discuss how we can implement inheritance in our programs, and what are some of the different types of inheritance.