Let\'s say that I have a class defined in moduleA.py which I want to add a method to, using some sort of loader method that takes a the name of a second module
Since meth2() is a function, it is a descriptor and you can bind it by calling the __get__() method.
def meth2(self):
return self.a + self.b
class ClassA(object):
def __init__(self,config):
super(ClassA, self).__init__()
self.a = 1
self.b = 2
self.meth1 = config.__get__(self, ClassA)
c = ClassA(meth2)
print c.meth1() #correctly prints 3