2016-12-08 | Paul Boddie | file changeset files shortlog | Ensure that base classes provide the attributes they use. Added tests demonstrating the use of attributes in base classes that are not necessarily defined in those classes or in some subclasses. |
paul@351 | 1 | class C: |
paul@351 | 2 | def f(self): |
paul@351 | 3 | return self.x |
paul@351 | 4 | |
paul@351 | 5 | class D(C): |
paul@351 | 6 | pass |
paul@351 | 7 | |
paul@351 | 8 | class E(C): |
paul@351 | 9 | def __init__(self, x): |
paul@351 | 10 | self.x = x |
paul@351 | 11 | |
paul@351 | 12 | d = D() |
paul@351 | 13 | print d.f() |
paul@351 | 14 | |
paul@351 | 15 | e = E(2) |
paul@351 | 16 | print e.f() |