micropython

Annotated tests/attributes_instance_bind_initialiser.py

804:c967b47fada4
2014-06-01 Paul Boddie Merged branches. syspython-as-target
paul@231 1
#!/usr/bin/env python
paul@231 2
paul@231 3
class B:
paul@231 4
    def __init__(self, y):
paul@231 5
        self.y = y
paul@231 6
paul@231 7
class A:
paul@231 8
    c1 = B
paul@231 9
    def __init__(self, b):
paul@231 10
        self.c2 = B
paul@231 11
paul@231 12
b = B(789)
paul@231 13
a = A(b)
paul@231 14
paul@231 15
b1 = A.c1(678)            # A.c1 is just a reference to B
paul@231 16
result_678 = b1.y
paul@231 17
b2 = a.c1(567)            # a.c1 is just a reference to B
paul@231 18
result_567 = b2.y
paul@231 19
b3 = a.c2(765)            # a.c2 is just a reference to B
paul@231 20
result_765 = b3.y
paul@231 21
paul@231 22
# vim: tabstop=4 expandtab shiftwidth=4