1 #!/usr/bin/env python 2 3 """ 4 This test illustrates the need for usage to be propagated forward to the 5 assignment within the loop. 6 """ 7 8 class C: 9 def e(self): # unused 10 return 1 11 12 def f(self): 13 return 1 14 15 class D: 16 def f(self): 17 return 2 18 19 def g(self): 20 return 3 21 22 class E: 23 def e(self): 24 return 4 25 26 def f(self): 27 return 0 # stops the test loop 28 29 def g(self): 30 return 5 31 32 def h(self): 33 return 6 34 35 def test_loop(obj, obj2): 36 # obj: f, g (from loop); f, h (outside loop) 37 while obj.f(): 38 # obj: g (in loop) 39 obj.g() 40 obj = obj2 # obj: e, f, h 41 obj.e() 42 # (test invoked again) 43 return obj.h() 44 45 c = C() 46 d = D() 47 e = E() 48 result_6 = test_loop(d, e) 49 50 # vim: tabstop=4 expandtab shiftwidth=4