2008-09-28 | Paul Boddie | file changeset files shortlog | Split the attributes2 test into smaller pieces. |
paul@157 | 1 | #!/usr/bin/env python |
paul@157 | 2 | |
paul@157 | 3 | class C: |
paul@157 | 4 | def g(self): |
paul@157 | 5 | return self.f # C.f with context self |
paul@157 | 6 | def f(self): pass |
paul@157 | 7 | |
paul@157 | 8 | def test(self): |
paul@157 | 9 | self.f() |
paul@157 | 10 | self.g() |
paul@157 | 11 | |
paul@157 | 12 | class D: |
paul@157 | 13 | f = C.f |
paul@157 | 14 | def g(self): |
paul@157 | 15 | return self.f # D.f with context preserved |
paul@157 | 16 | |
paul@157 | 17 | def test(self): |
paul@157 | 18 | self.f(2) |
paul@157 | 19 | self.g() |
paul@157 | 20 | |
paul@157 | 21 | class E(C): |
paul@157 | 22 | def g(self): |
paul@157 | 23 | return self.f # C.f with context self |
paul@157 | 24 | |
paul@157 | 25 | def test(self): |
paul@157 | 26 | self.f() |
paul@157 | 27 | self.g() |
paul@157 | 28 | |
paul@157 | 29 | C.f |
paul@157 | 30 | D.f |
paul@157 | 31 | E.f |
paul@157 | 32 | |
paul@157 | 33 | c = C() |
paul@157 | 34 | d = D() |
paul@157 | 35 | e = E() |
paul@157 | 36 | |
paul@157 | 37 | x = c.f # bound C.f == c.g() |
paul@157 | 38 | y = d.f # unbound C.f == d.g() |
paul@157 | 39 | z = e.f # bound E.f == e.g() |
paul@157 | 40 | |
paul@157 | 41 | # vim: tabstop=4 expandtab shiftwidth=4 |