I'm using a class from a package in Python to which I pass functions that must have only one argument, e.g. :
def exampleFunction1(only_argument_1):
doSomething1(only_argument_1) #perform some operations
Then, once defined all the needed functions in the above way, I need to pass them in this way:
python_package_class.function1 = exampleFunction1
python_package_class.function2 = exampleFunction2
python_package_class.function3 = exampleFunction3
Now let's imagine that the doSomething is equal for all my functions, except for the fact that it requires another parameter that change, e.g. (1, 2 and 3 are just examples, the argument can be anything):
def exampleFunction1(only_argument_1):
doSomething(1, only_argument_1) #perform some operations
def exampleFunction2(only_argument_2):
doSomething(2, only_argument_2) #perform some operations
def exampleFunction3(only_argument_3):
doSomething(3, only_argument_3) #perform some operations
This could be greatly simplified by defining only one exampleFunction to which I pass two parameters:
def exampleFunction(a, only_argument_1):
doSomething(a, only_argument_1) #perform some operations
But, unfortunately, this would give me an error since, as I said, the Python package that I'm using strictly requires functions accepting only one argument.
So my question is, is there an "implicit way" to pass the argument a to exampleFunction in the following code line?
python_package_class.function1 = exampleFunction