2014-03-09 | Paul Boddie | file changeset files shortlog | Added another example illustrating that attributes must be defined "internally" at least once in order to be associated with a class. | syspython-as-target |
paul@782 | 1 | #!/usr/bin/env python |
paul@782 | 2 | |
paul@782 | 3 | class C: |
paul@782 | 4 | def __init__(self, a): |
paul@782 | 5 | self.a = a |
paul@782 | 6 | |
paul@782 | 7 | def f(obj, b): |
paul@782 | 8 | obj.a |
paul@782 | 9 | obj.b = b |
paul@782 | 10 | |
paul@782 | 11 | c = C(1) |
paul@782 | 12 | f(c, 2) |
paul@782 | 13 | result_1 = c.a |
paul@782 | 14 | result_2 = c.b |
paul@782 | 15 | |
paul@782 | 16 | # vim: tabstop=4 expandtab shiftwidth=4 |