micropython

Annotated tests/attributes_instance.py

655:c52c50dca9dc
2013-05-01 Paul Boddie Added some tests of dynamic attribute access using getattr and string constants. syspython-as-target
paul@219 1
#!/usr/bin/env python
paul@219 2
paul@219 3
class C:
paul@219 4
    def __init__(self, value):
paul@219 5
        self.instattr = value
paul@219 6
paul@219 7
    def update(self, value):
paul@219 8
        self.attr = value
paul@219 9
paul@219 10
c = C(789)
paul@219 11
c.update(987)
paul@228 12
result_789 = c.instattr
paul@228 13
result_987 = c.attr
paul@219 14
paul@219 15
# vim: tabstop=4 expandtab shiftwidth=4