filmov
tv
hybrid inheritance in python | multipath inheritance in python

Показать описание
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
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
Комментарии