Lichen

tests/getattr.py

579:d3811f95c60e
2017-02-13 Paul Boddie Moved minimum parameter information to parameter tables, adding maximum parameter information (also fixing tests in the __invoke function), and thus making parameter tables distinct according to minimum parameters and parameter member details. This changes the __attr size to a single word and thus reduces the program data volume even further. method-wrapper-for-context
     1 class C:     2     def __init__(self):     3         self.x = 1     4         self.y = 2     5         self.z = 3     6      7 class D:     8     def __init__(self):     9         self.x = 4    10         self.y = 5    11         self.z = 6    12     13 c = C()    14 d = D()    15     16 attrnames = ["a", "b", "c", "x", "y", "z"]    17     18 print ". c d"    19     20 for attrname in attrnames:    21     print attrname, hasattr(c, attrname) and "1" or "0", hasattr(d, attrname) and "1" or "0"    22     23 print    24 print ". c d"    25     26 for attrname in attrnames:    27     print attrname,    28     try:    29         v = getattr(c, attrname)    30         print v,    31     except AttributeError:    32         print "?",    33     34     try:    35         v = getattr(d, attrname)    36         print v    37     except AttributeError:    38         print "?"    39     40 try:    41     setattr(c, "x", 7)    42 except NotImplementedError, exc:    43     print 'setattr(c, "x", 7): not implemented:', exc.name