Consider the following example:
class foo:
def __init__(self):
print ("Constructor")
def testMethod(self,val):
print ("Hello " + val)
def test(self):
ptr = self.testMethod("Joe") <---- Anyway instead of calling self.testMethod with parameter "Joe" I could simple bind the parameter Joe to a variable ?
ptr()
k = foo()
k.test()
In the defintion test is it possible for me to create a variable which when called calls the method self.testMethod with the parameter "Joe" ?
def test(self, name): ptr=self.testMethod(name)? Then you can call k.test("Joe")from functools import partial, thenself.callable = partial(self.testMethod, 'Joe')?