VOOZH about

URL: https://www.geeksforgeeks.org/python/what-is-hybrid-inheritance-in-python/

⇱ What Is Hybrid Inheritance In Python? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

What Is Hybrid Inheritance In Python?

Last Updated : 23 Jul, 2025

Inheritance is a fundamental concept in object-oriented programming (OOP) where a class can inherit attributes and methods from another class. Hybrid inheritance is a combination of more than one type of inheritance. In this article, we will learn about hybrid inheritance in Python.

Hybrid Inheritance is a Type of Inheritance for know more about inheritance Visit.

What is Hybrid Inheritance in Python?

Hybrid inheritance is a blend of multiple inheritance types. In Python, the supported types of inheritance are single, multiple, multilevel, hierarchical, and hybrid. In hybrid inheritance, classes are derived from more than one base class, creating a complex inheritance structure.

Syntax of Hybrid Inheritance in Python

For example, a class can inherit from one base class while also serving as a base class for another class. This creates a chain of inheritance, leading to the hybrid structure.

class BaseClass1:

# Attributes and methods of BaseClass1

class BaseClass2:

# Attributes and methods of BaseClass2

class DerivedClass(BaseClass1, BaseClass2):

# Attributes and methods of DerivedClass

Explanation:

  • BaseClass1 and BaseClass2 are base classes.
  • DerivedClass is the derived class inheriting from BaseClass1 and BaseClass2.

Python Hybrid Inheritance - Examples

Below, are the example of Code Examples of Hybrid Inheritance in Python:

Example 1: Hybrid Inheritance with Platypus Class

In this example, below code shows hybrid inheritance in Python. The Platypus class inherits from both Mammal and Bird classes, showcasing characteristics of both types of animals. This allows Platypus objects to access methods such as speak() from Animal class, give_birth() from Mammal class, and lay_eggs() from Bird class, reflecting the unique attributes of this hybrid creature.


Output
Animal speaks
Mammal gives birth
Bird lays eggs

Example 2: Hybrid Inheritance: Amphibious Vehicles in Python

In this example, AmphibiousVehicle class showcases hybrid inheritance by inheriting from both Car and Boat classes. It inherits characteristics of both types of vehicles, being able to drive like a car and sail like a boat. The method amphibious_action demonstrates a behavior specific to amphibious vehicles, which can both drive and sail.


Output
Vehicle moves
Car drives
Boat sails
Amphibious vehicle can both drive and sail
Comment
Article Tags: