2017-01-23 | Paul Boddie | raw annotate files changeset graph | Added another, shorter test of get_using, commenting the existing test slightly. |
1 class C: 2 def __init__(self): 3 self.x = 123 4 5 def f(self): 6 print self 7 return self.x 8 9 c = C() 10 f = C.f 11 fn = get_using(C.f, c) 12 print fn # __main__.C.f 13 print fn() # 123 14 fn = get_using(C.f, C) 15 print fn # __main__.C.f 16 try: 17 print fn() # fails 18 except UnboundMethodInvocation: 19 print "fn(): method is unbound"