次のようなpythonファイルを作成します。
class A(object):
def update(self, str):
pass
def say(self, str):
print "I update: " + str
def fun(obj, str):
obj.say(str)
a = A()
import types
setattr(A, "update", types.MethodType(fun, None, A))
a.update("hello")
b = A()
b.update("world?")
クラスの振る舞いを変更し、オブジェクト b が変更されました。しかし、私はオブジェクト a だけを変更したいです。Pythonでオブジェクトのメソッドを変更するには?