micropython

tests/getattr_instance_fake.py

519:814bd122d84d
2012-06-04 Paul Boddie Updated the documentation to reflect class attribute assignment policies. Added tests to demonstrate class attribute rebinding.
     1 #!/usr/bin/env python     2      3 class C:     4     x = 1     5      6 class D:     7     x = 2     8      9 def getattr(obj, name):    10     return obj.x    11     12 c = C()    13 d = D()    14 result_1 = getattr(c, "x") # "x" should be a str, since no dynamic access is done    15 result_2 = getattr(d, "x")    16     17 # vim: tabstop=4 expandtab shiftwidth=4