Skip to main content

/docs/images/banner.jpg

Python

Multiple Inheritance

Title: WAP to implement multiple inheritance with two base classes

# WAP to implement multiple inheritance with two base classes

class A:
def __init__(self):
print("Class A")


class B:
def __init__(self):
print("Class B")


class C(A, B):
def __init__(self):
print("Class C")
super().__init__()
# by default super() calls the first base class
# use A.__init__() to call the __init__ method of class A
# use B.__init__() to call the __init__ method of class B


c = C()

# Output:
# Class C
# Class A