2012-07-04 | Paul Boddie | raw annotate files changeset graph | Simplified the registration of modified globals by making sure they are known before the module-level code is visited, thus helping to avoid the gathering of attribute usage for names that are known to be modified. (External modification of globals may require usage revocation support, however, since such modification would not be known until module code is being visited.) |
1 #!/usr/bin/env python 2 3 class C: 4 p = 123 5 6 class D: 7 p = 456 8 9 x = C 10 11 def change(): 12 global x 13 x = D 14 15 def use(y): 16 return y.p # usage of p 17 18 def f(): 19 return x.p # ambiguous 20 21 change() 22 result1_456 = x.p 23 result2_456 = f() 24 result3_456 = use(x) 25 26 # vim: tabstop=4 expandtab shiftwidth=4