Python Inheritance Types

As we have seen so far, the main advantage of inheritance is code reusability. The members of the super class are reusable in the sub classes. Let's remember that all classes in Python are built from a single super class called 'object'. If a programmer creates his own classes, by default object class will become super class for them internally. This is the reason, sometimes while creating any new class, we mention the object class name in parentheses as:

class Myclass(object):

Here, we are indicating that object is the super class for Myclass. Of course, writing object class name is not mandatory and hence the preceding code is equivalent to writing:

class Myclass:

Now, coming to the types of inheritance, there are mainly 2 types of inheritance available. They are:

  • Single inheritance
  • Multiple inheritance