I have a function which takes a lot of parameters, and since I dont want to remember their positions I decided to use named arguments
def f(a=None, b=None, c=None):
print a,b,c
f('test', c=5, b='second param')
>>> test second param 5
now, usually I only change one parameter at a time, so i want to call the function by only typing f(c=3.14) with the intended result being f(a=a, b=b, c=3.14), namely every argument that is not explicitely passed should be read from the local scope.
But of course it doesnt work since to use named arguments I have to set a default value, if I use **kwargs instead, it simply ignores the arguments
def f(**kwargs):
print a,b,c
a=1; b=2; c=3
f(a=2, b=4, c=8)
>>> 1 2 3 # instead of 2 4 8
I used to define a new function for each parameter but I dont like this approach although it has been the most effective so far
def fc(c_new):
return f(a, b, c_new)
How do I make the function use the variables in its current scope as default values for its named arguments?