2009-05-30 | Paul Boddie | raw annotate files changeset graph | Split the descendant of the old classes test into two more specific tests of attribute binding and methods/callables. |
1 #!/usr/bin/env python 2 3 class B: 4 def __init__(self, y): 5 self.y = y 6 7 class A: 8 c1 = B 9 def __init__(self, b): 10 self.c2 = B 11 self.c3 = b 12 13 b = B(789) 14 a = A(b) 15 16 b1 = A.c1(678) # A.c1 is just a reference to B 17 result_678 = b1.y 18 b2 = a.c1(567) # a.c1 is just a reference to B 19 result_567 = b2.y 20 b3 = a.c2(765) # a.c2 is just a reference to B 21 result_765 = b3.y 22 23 # vim: tabstop=4 expandtab shiftwidth=4