2010-09-07 | Paul Boddie | file changeset files shortlog | Changed attribute usage tracking to consider branching and separate usage possibilities in a slightly more rigourous way. Attempted to add isinstance support. Added tests of the revised attribute usage support. |
paul@288 | 1 | #!/usr/bin/env python |
paul@288 | 2 | |
paul@288 | 3 | class C: |
paul@288 | 4 | def f(self): |
paul@288 | 5 | return 1 |
paul@288 | 6 | |
paul@288 | 7 | class D: |
paul@288 | 8 | def f(self): |
paul@288 | 9 | return 2 |
paul@288 | 10 | |
paul@288 | 11 | def g(self): |
paul@288 | 12 | return 3 |
paul@288 | 13 | |
paul@288 | 14 | class E: |
paul@288 | 15 | def f(self): |
paul@288 | 16 | return 4 |
paul@288 | 17 | |
paul@288 | 18 | def h(self): |
paul@288 | 19 | return 5 |
paul@288 | 20 | |
paul@288 | 21 | def test_conditional(obj): |
paul@288 | 22 | # obj: C, D, E (f) |
paul@377 | 23 | if obj.f(): # C, D, E (f) |
paul@377 | 24 | return obj.g() # D (f, g) |
paul@288 | 25 | else: |
paul@377 | 26 | return obj.h() # E (f, h) |
paul@377 | 27 | # # (f, g) ^ (f, h) |
paul@288 | 28 | |
paul@288 | 29 | c = C() |
paul@288 | 30 | d = D() |
paul@288 | 31 | e = E() |
paul@377 | 32 | result1_3 = test_conditional(d) |
paul@288 | 33 | |
paul@288 | 34 | # vim: tabstop=4 expandtab shiftwidth=4 |