Python: call constructor of the super class








  • Option 1:

    class A(object):
    def __init__(self):
    print "world"

    class B(A):
    def __init__(self):
    print "hello"
    super(B, self).__init__()
  • Option 2:

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

    class B(A):
    def __init__(self):
    print "hello"
    A.__init__(self)



No comments:

Post a Comment