2018-07-05 | Paul Boddie | file changeset files shortlog | Employed sets for attributes and providers referenced by accesses. This causes various attributes to be identified definitively in the access plans and instruction sequences. |
paul@360 | 1 | class C: |
paul@360 | 2 | def __init__(self): |
paul@360 | 3 | self.x = 1 |
paul@360 | 4 | self.y = 2 |
paul@360 | 5 | self.z = 3 |
paul@360 | 6 | |
paul@360 | 7 | class D: |
paul@360 | 8 | def __init__(self): |
paul@360 | 9 | self.x = 4 |
paul@360 | 10 | self.y = 5 |
paul@360 | 11 | self.z = 6 |
paul@360 | 12 | |
paul@360 | 13 | c = C() |
paul@360 | 14 | d = D() |
paul@360 | 15 | |
paul@360 | 16 | attrnames = ["a", "b", "c", "x", "y", "z"] |
paul@360 | 17 | |
paul@360 | 18 | print ". c d" |
paul@360 | 19 | |
paul@360 | 20 | for attrname in attrnames: |
paul@360 | 21 | print attrname, hasattr(c, attrname) and "1" or "0", hasattr(d, attrname) and "1" or "0" |
paul@360 | 22 | |
paul@360 | 23 | print |
paul@360 | 24 | print ". c d" |
paul@360 | 25 | |
paul@360 | 26 | for attrname in attrnames: |
paul@360 | 27 | print attrname, |
paul@360 | 28 | try: |
paul@360 | 29 | v = getattr(c, attrname) |
paul@494 | 30 | print v, |
paul@360 | 31 | except AttributeError: |
paul@494 | 32 | print "?", |
paul@360 | 33 | |
paul@360 | 34 | try: |
paul@360 | 35 | v = getattr(d, attrname) |
paul@494 | 36 | print v |
paul@360 | 37 | except AttributeError: |
paul@494 | 38 | print "?" |
paul@468 | 39 | |
paul@468 | 40 | try: |
paul@468 | 41 | setattr(c, "x", 7) |
paul@468 | 42 | except NotImplementedError, exc: |
paul@468 | 43 | print 'setattr(c, "x", 7): not implemented:', exc.name |