from types import UnboundMethodType class class1(object):
def fun1(self):
print 'fun1' oldfun1 = class1.fun1 def fun1new(self):
print 'fun1new'
return oldfun1(self) class1.fun1 = UnboundMethodType(fun1new, None, class1) class1().fun1()
最终输出
fun1new
fun1