Python: Multiple Inheritance

class BigBoxParent:
    def __init__(self):
        print("BigBoxParent __init__")

    def myParentMethOne(self):
        print("my Parent Method One")
        
    def myParentMethTwo(self):
        print("my Parent Method Two")
        
class NewParent:
    def __init__(self):
        print("NewParent __init__")
        
    def newParentMethOne(self):
        print("new Parent Method one")
        
    def newParentMethTwo(self):
        print("new Parent Method Two")
        
class BigBoxChild(BigBoxParent, NewParent):
    def __init__(self):
        NewParent.__init__(self)
        print("BigBoxChild __init__")
        
    def myChildMethodOne(self):
        print("my Child Method One")
        

child_obj = BigBoxChild()
child_obj.myChildMethodOne()
child_obj.myParentMethOne()
child_obj.newParentMethTwo()
Python

Output:

NewParent __init__
BigBoxChild __init__

My Child Method One
my Parent Method One
new Parent Method Two
Plaintext

Leave a Comment


The reCAPTCHA verification period has expired. Please reload the page.