What is the best practice in python to check if at least one of the default parameters is specified for a function?
Suppose we have some function:
def some_function(arg_a=None, arg_b=None, arg_c=False)
with some default options. In my case, I need to check if the parameter is specified arg_aor arg_b. So I decided to implement something like this:
def some_function(arg_a=None, arg_b=None, arg_c=False):
...
if arg_a is not None:
...
elif arg_b is not None:
...
else:
raise ValueError('Expected either arg_a or arg_b args')
...
...
So, what is an even more pythonic way to implement such functionality?
source
share