python 类间的有趣调用
代码
class A:
def __init__(self):
self.x = 111
self.y = 'test'
def testA(self, inp):
print("in a class")
print("{}--{}--{}".format(self.x, self.y, inp*2))
class B:
def __init__(self):
self.a = A()
def testB(self):
print("in b class")
self.a.testA("la")
class C:
def __init__(self):
self.b = B()
self.a = self.b.a
def testC(self):
print("in c class")
self.a.testA("ready?")
self.b.a.testA(11)
demo = C()
demo.testC()