hybrid inheritance in python | multipath inheritance in python

Опубликовано: 17 Май 2020
на канале: Tarun Sir
1,557
32

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()
obj.display()
obj.write()
obj.printdata()

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 python | multipath inheritance in python длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Tarun Sir 17 Май 2020, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 1,557 раз и оно понравилось 32 зрителям. Приятного просмотра!