Understanding Python super() with __init__() methods [duplicate]

Why is super() used?

Is there a difference between using Base.__init__ and super().__init__?

class Base(object):
    def __init__(self):
        print "Base created"
        
class ChildA(Base):
    def __init__(self):
        Base.__init__(self)
        
class ChildB(Base):
    def __init__(self):
        super(ChildB, self).__init__()
        
ChildA() 
ChildB()

7

Leave a Comment