micropython

Annotated tests/attributes_instance_assignment.py

804:c967b47fada4
2014-06-01 Paul Boddie Merged branches. syspython-as-target
paul@485 1
#!/usr/bin/env python
paul@485 2
paul@485 3
class C:
paul@485 4
    def __init__(self, x):
paul@485 5
        self.x = x
paul@485 6
        self.z = None
paul@485 7
paul@485 8
class D:
paul@485 9
    def __init__(self, y):
paul@485 10
        self.y = y
paul@485 11
        self.z = None
paul@485 12
paul@485 13
def f(a):
paul@485 14
    if a.z:
paul@485 15
        pass
paul@485 16
    a.x = 3
paul@485 17
paul@487 18
def g(a):   # {{z}, {x, z}}
paul@487 19
    if a.z:
paul@487 20
        a.x # {x, z}
paul@487 21
            # {z} (else)
paul@487 22
    a.z = 4
paul@487 23
paul@485 24
c = C(1)
paul@487 25
d = D(0)
paul@485 26
f(c)
paul@487 27
g(d)
paul@485 28
result_3 = c.x
paul@487 29
result_4 = d.z
paul@485 30
paul@485 31
# vim: tabstop=4 expandtab shiftwidth=4