pyhon
Python で、クラスに対してあとから動的にメソッドを追加するには、new モジュールを使う。 import new class Foo(object): pass obj = Foo() obj.f1("abc") #=> AttributeError: 'Foo' object has no attribute 'f1' def f1(self, arg): print repr(arg) Fo…
Python で、クラスに対してあとから動的にメソッドを追加するには、new モジュールを使う。 import new class Foo(object): pass obj = Foo() obj.f1("abc") #=> AttributeError: 'Foo' object has no attribute 'f1' def f1(self, arg): print repr(arg) Fo…