I have a function A with two named parameters and a function B that will optimize the result of A, changing its arguments. The algorithm is the same regardless I optimize the first or the second parameter. Can I pass to B the name and the value of needed parameter? The question raised while looking at scikit-learn functions of machine learning.
I want something like this:
def A(p1 = 0, p2 = 0):
print(p1 + p2)
def B(par_name, par_val):
...
B will call A with given parameter.
B("p1", 1) => A(p1 = 1, p2 = 0)
B("p2", 1) => A(p1 = 0, p2 = 1)