2021-10-30 | Paul Boddie | file changeset files shortlog | Fixed expected result in comment. |
paul@46 | 1 | class C: |
paul@46 | 2 | def __init__(x, y, z): # no explicit self |
paul@46 | 3 | self.x = x |
paul@46 | 4 | self.y = y |
paul@46 | 5 | self.z = z |
paul@46 | 6 | |
paul@46 | 7 | def c(): |
paul@46 | 8 | return self.x |
paul@46 | 9 | |
paul@46 | 10 | class D(C): |
paul@46 | 11 | def d(): |
paul@46 | 12 | return self.y |
paul@46 | 13 | |
paul@46 | 14 | class E(D): |
paul@46 | 15 | def c(): |
paul@46 | 16 | return self.z |
paul@46 | 17 | |
paul@46 | 18 | c = C(1, 2, 3) |
paul@46 | 19 | d = D(1, 2, 3) |
paul@46 | 20 | e = E(1, 2, 3) |
paul@46 | 21 | |
paul@214 | 22 | print c.c() # 1 |
paul@214 | 23 | print d.c() # 1 |
paul@214 | 24 | print e.c() # 3 |
paul@214 | 25 | print d.d() # 2 |
paul@214 | 26 | print e.d() # 2 |