So I have some funciton
def fun(x,y=None):
# Do some stuff
and I want to minimize this function over x, but sometimes I will want to have an additional argument y. (Essentially, I want y to always take its default value, except when I'm minimizing.)
Usually, if the function was just def fun(x,y):
I'd be able to do scipy.optimize.minimize(x,args=(y))
. But what do I do when y is an optional variable? putting args=(y=value)
is giving me invalid syntax, (and, sure, it looks very wrong), but I'm not sure what the correct syntax would be.
I'm using Python 3.7 if that's relevant.