Limitation(s):
- can make programs difficult to read
- when method is invoked, it is sometimes not clear where to find its definition esp. in a large project relevant code may be scattered among several modules
class A(object):
def __init__(self):
self.a = 'A'
def printMe(self):
print("A's info: {}".format(self.a))
class B:
def __init__(self):
self.b = 'B'
def printMe(self):
print("B's info: {}".format(self.b))
class C(B, A): # what happens if you change order?
def __init__(self):
A.__init__(self)
B.__init__(self)
self.c = 'C'
def printMe(self):
print("A's info: {}".format(self.a))
print("B's info: {}".format(self.b))
print("C's info: {}".format(self.c))
obja = A()
obja.printMe()
objb = B()
objb.printMe()
objc = C()
objc.printMe()
A's info: A B's info: B A's info: A B's info: B C's info: C
# How can objects of type C can print their c property info