1 #!/usr/bin/env python 2 3 def e(x): pass 4 5 class C: 6 def h(self): 7 self.m = self.f 8 return self.m # not known 9 def g(self): 10 return self.f # C.f with context self 11 def f(self): pass 12 e = e 13 14 def test(self): 15 self.e() 16 self.f() 17 self.g() 18 self.h() 19 20 class D: 21 e = C.e 22 f = C.f 23 def g(self): 24 return self.f # D.f with context preserved 25 def h(self): 26 self.m = self.f 27 return self.m # not known 28 29 def test(self): 30 self.e(1) 31 self.f(2) 32 self.g() 33 self.h() 34 35 class E(C): 36 def g(self): 37 return self.f # C.f with context self 38 def h(self): 39 self.m = self.f 40 return self.m # not known 41 42 def test(self): 43 self.e() 44 self.f() 45 self.g() 46 self.h() 47 48 C.f 49 D.f 50 E.f 51 52 c = C() 53 d = D() 54 e = E() 55 56 x = c.f # bound C.f == c.h() == c.g() 57 y = d.f # unbound C.f == d.h() == d.g() 58 z = e.f # bound E.f == e.h() == e.g() 59 60 p = c.e # bound C.e 61 q = d.e # unbound C.e 62 r = e.e # bound E.e 63 64 # vim: tabstop=4 expandtab shiftwidth=4