7
7stud
When I run the following code and call super() in the Base class's
__init__ () method, only one Parent's __init__() method is called.
class Parent1(object):
def __init__(self):
print "Parent1 init called."
self.x = 10
class Parent2(object):
def __init__(self):
print "Parent2 init called."
self.y = 15
class Base(Parent1, Parent2):
def __init__(self):
super(Base, self).__init__()
self.z = 20
b = Base()
--output:--
Parent1 init called.
__init__ () method, only one Parent's __init__() method is called.
class Parent1(object):
def __init__(self):
print "Parent1 init called."
self.x = 10
class Parent2(object):
def __init__(self):
print "Parent2 init called."
self.y = 15
class Base(Parent1, Parent2):
def __init__(self):
super(Base, self).__init__()
self.z = 20
b = Base()
--output:--
Parent1 init called.