1 #!/usr/bin/env python 2 3 """ 4 This test attempts to demonstrate that the usage associated with the global 5 'obj' cannot be reliably calculated since a function exists that rebinds the 6 name. 7 """ 8 9 class C: 10 def f(self): # unused but retained 11 return 1 12 13 class D: 14 def f(self): 15 return 2 16 17 def g(self): 18 return 3 19 20 class E: 21 def f(self): # unused but retained 22 return 4 23 24 def h(self): # unused 25 return 5 26 27 def change_global(): 28 global obj 29 obj = E() # changes the global, potentially invalidating usage observations 30 31 c = C() 32 d = D() 33 e = E() 34 35 obj = c 36 obj = d 37 38 if obj.f(): 39 obj.g() 40 change_global() 41 x = obj.f() 42 else: 43 x = 2 44 45 result_4 = x 46 47 # vim: tabstop=4 expandtab shiftwidth=4