2013-10-31 | Paul Boddie | file changeset files shortlog | Added remarks about local namespaces and name usage observations. | syspython-as-target |
paul@726 | 1 | #!/usr/bin/env python |
paul@726 | 2 | |
paul@726 | 3 | class C: |
paul@726 | 4 | x = 123 |
paul@726 | 5 | |
paul@726 | 6 | class D: |
paul@726 | 7 | x = 456 |
paul@726 | 8 | |
paul@726 | 9 | a = C() |
paul@726 | 10 | b = D() |
paul@726 | 11 | i = 4 |
paul@726 | 12 | |
paul@726 | 13 | while i > 0: |
paul@726 | 14 | i -= 1 |
paul@726 | 15 | if i == 2: |
paul@726 | 16 | a = D() # influences the loop |
paul@726 | 17 | continue |
paul@726 | 18 | if i == 3: |
paul@726 | 19 | b = a # type of a is C or D (by flow analysis) |
paul@726 | 20 | |
paul@726 | 21 | result_123 = b.x |
paul@726 | 22 | result_456 = a.x |
paul@726 | 23 | |
paul@726 | 24 | # vim: tabstop=4 expandtab shiftwidth=4 |