In my current project, I have a function which calls a second, nested function. This nested function has one obligatory input (x), but can demand a number of other arguments as well (say: y, z). Without changing the structure of the outer function, is there a way to pass the optional arguments to the inner/nested function? Imagine, for example, something like this:
# Define the outer function
def outer_function(x,args):
# This function calls a nested function
def inner_function(x,y,z):
return x*y + z
return inner_function(x,args)
# The following does NOT work
result = outer_function(x = 1, args = (2,3))
The SciPy optimizers, for example, have a similar capability, where you only require x as a primary input and can pass any secondary inputs as a tuple through the 'args' variable to the inner function we seek to optimize.
Do you know how I can implement this? Note that I do not want to unpack the 'args' variable in the outer function. If at all possible, I would like to pass these arguments directly on to the inner function.