2011-11-01 | Paul Boddie | file changeset files shortlog | Introduced attribute user finalisation to modules. |
paul@412 | 1 | #!/usr/bin/env python |
paul@412 | 2 | |
paul@412 | 3 | class C: |
paul@412 | 4 | x = 1 |
paul@412 | 5 | |
paul@412 | 6 | class D: |
paul@412 | 7 | x = 2 |
paul@412 | 8 | |
paul@412 | 9 | def getattr(obj, name): |
paul@412 | 10 | return obj.x |
paul@412 | 11 | |
paul@412 | 12 | c = C() |
paul@412 | 13 | d = D() |
paul@412 | 14 | result_1 = getattr(c, "x") # "x" should be a str, since no dynamic access is done |
paul@412 | 15 | result_2 = getattr(d, "x") |
paul@412 | 16 | |
paul@412 | 17 | # vim: tabstop=4 expandtab shiftwidth=4 |