I have a function with two optional parameters:
def func(a=0, b=10):
return a+b
Somewhere else in my code I am doing some conditional a
Going by the now-deleted comments to the question that the check is meant to be for the variables being None
rather than being falsey, change func
so that it handles the arguments being None
:
def func(a=None, b=None):
if a is None:
a = 0
if b is None:
b = 10
And then just call func(a, b)
every time.