micropython

Annotated tests/class_class_attr_indirect.py

655:c52c50dca9dc
2013-05-01 Paul Boddie Added some tests of dynamic attribute access using getattr and string constants. syspython-as-target
paul@401 1
#!/usr/bin/env python
paul@401 2
paul@401 3
class A:
paul@401 4
    pass
paul@401 5
paul@401 6
class B(A):
paul@401 7
    pass
paul@401 8
paul@401 9
class C:
paul@401 10
    pass
paul@401 11
paul@401 12
a = A.__class__
paul@401 13
b = B.__class__
paul@401 14
c = C.__class__
paul@401 15
paul@401 16
result_1 = a is type and 1 or 0
paul@401 17
result_2 = b is type and 2 or 0
paul@401 18
result_3 = c is type and 3 or 0
paul@401 19
paul@401 20
# vim: tabstop=4 expandtab shiftwidth=4