2010-06-12 | Paul Boddie | file changeset files shortlog | Fixed scope handling where names are imported into namespaces. Added a simple iter built-in function. Made the xrange test use the iteration protocol. |
paul@187 | 1 | #!/usr/bin/env python |
paul@187 | 2 | |
paul@187 | 3 | class B: |
paul@230 | 4 | def __init__(self, y): |
paul@230 | 5 | self.y = y |
paul@230 | 6 | def m(self, x): |
paul@230 | 7 | return x |
paul@187 | 8 | |
paul@187 | 9 | class A: |
paul@230 | 10 | m1 = B.m |
paul@230 | 11 | def __init__(self, b): |
paul@230 | 12 | self.m2 = B.m |
paul@230 | 13 | self.m3 = b.m |
paul@187 | 14 | |
paul@230 | 15 | b = B(789) |
paul@230 | 16 | a = A(b) |
paul@230 | 17 | result_123 = A.m1(b, 123) # A.m1 is unbound |
paul@230 | 18 | result_234 = a.m1(b, 234) # a.m1 is unbound |
paul@230 | 19 | result_345 = a.m2(b, 345) # a.m2 is unbound |
paul@230 | 20 | result_456 = a.m3(456) # a.m3 is bound to b |
paul@187 | 21 | |
paul@187 | 22 | # vim: tabstop=4 expandtab shiftwidth=4 |