Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python change function of object

from types import MethodType

class A(object):
    def m(self):
        print 'aaa'

a = A()

def new_m(self):
    print 'bbb'

a.m = MethodType(new_m, a)
 
PREVIOUS NEXT
Tagged: #python #change #function #object
ADD COMMENT
Topic
Name
6+5 =