hybrid inheritance in python | multipath inheritance in python

preview_player
Показать описание
In this video you will learn how to implement hybrid inheritance and multipath inheritance in python.

Hybrid Inheritance
In the hybrid inheritance, we use more than one type of inheritance in the inheritance hierarchy.
The following example shows the hybrid inheritance:

class A:
def output(self):
print("Hello from output() of A class")

class B(A):
def display(self):
print("Hello from display() of B class ")
class C(A):
def write(self):
print("Hello from write() of C Class")

class D(B,C):
def printdata(self):
print("Hello from printdata() of D class")

obj=D()

In the above example the B and C classes are inherited from A using hierarchical inheritance, and class D is inherited from class B and class C using the multiple inheritance, so this is the concept of hybrid inheritance. Here class B, and C receives the features of class A. Class D receives features of A via B and C, and also receives the features of both class B and class C, and it can also add its own features.
This particular example can also be called as Multi Path Inheritance, as class D receives the features of class A via multiple paths.

#python_by_tarun_sir #tarun_sir #python #tarun_sir_python #python_video_68 #multipath_inheritance_in_python #python_tutorial #hybrid_inheritance_in_python
Рекомендации по теме
Комментарии
Автор

Is their any concept of virtual in python to access class A method in class D as they are coming from two path

shubhamsharma-rsnt
join shbcf.ru