micropython

tests/failure/importer.py

655:c52c50dca9dc
2013-05-01 Paul Boddie Added some tests of dynamic attribute access using getattr and string constants. syspython-as-target
     1 #!/usr/bin/env python     2      3 import imported     4      5 imported.attr = 456 # detected with warning     6      7 m = imported     8 imported.a = 9      # detected with warning     9 m.a = 8             # detected with warning (m is always imported)    10     11 imported.x = 1      # detected with warning (despite no collision)    12     13 class C:            # hack: make an attribute called y known to the system    14     y = None        # hack: this prevents compilation errors with the statements    15                     # hack: below    16     17 n = None    18 n = imported    19 n.y = 2             # not detected due to reassignment of n    20 n.y = 3             # not detected due to reassignment of n    21     22 # vim: tabstop=4 expandtab shiftwidth=4