Is it possible to pass arbitrary number of named default arguments to a Python function conditionally ?
For eg. there's a function:
def func(arg, arg2='', arg3='def')
Now logic is that I have a condition which determines if arg3 needs to be passed, I can do it like this:
if condition == True:
func('arg', arg2='arg2', arg3='some value')
else:
func('arg', arg2='arg2')
Question is, can I have a shorthand like:
func('arg', 'arg2', 'some value' if condition == True else # nothing so default gets picked
)