parent and child class in python code example
Example 1: Inheritance example python
class Parent:
def abc(self):
print("Parent")
class LeftChild(Parent):
def pqr(self):
print("Left Child")
class RightChild(Parent):
def stu(self):
print("Right Child")
class GrandChild(LeftChild,RightChild):
def xyz(self):
print("Grand Child")
obj1 = LeftChild()
obj2 = RightChild()
obj3 = GrandChild()
obj1.abc()
obj2.abc()
obj3.abc()
Example 2: python inherit parent class init
SuperClass.__init__(self, variable)