micropython

Annotated tests/attributes_class_inherited.py

655:c52c50dca9dc
2013-05-01 Paul Boddie Added some tests of dynamic attribute access using getattr and string constants. syspython-as-target
paul@645 1
#!/usr/bin/env python
paul@645 2
paul@645 3
class C:
paul@645 4
    x = 1
paul@645 5
paul@645 6
class D(C):
paul@645 7
    pass
paul@645 8
paul@645 9
def f(c):
paul@645 10
    return c.x
paul@645 11
paul@645 12
result_1 = f(C)
paul@645 13
result_2 = f(D)
paul@645 14
paul@645 15
# vim: tabstop=4 expandtab shiftwidth=4