Class inheritance

In this section, we will learn about inheritance. Inheritance allows us to inherit methods and attributes of the parent class. By inheritance, a new child class automatically gets all of the methods and attributes of the existing parent class. The syntax is given as follows:

class DerivedClassName(BaseClassName):   <statement-1>   .   . .   <statement-N>

If you remember, in Chapter 10, File Handling and Exceptions, we had inherited the built-in class exception. Starting with the existing code, let's make the instructor class, which would inherit the method of the Leapx_org class. Refer to the code in classinheri1.py:

class Leapx_org():   mul_num = 1.20   count= 0   def __init__(self,first,last,pay):      self.f_name = first self.l_name ...

Get Learn Python in 7 Days now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.