This is maybe a little different than just the traditional *args **kwargs paradigm:
I have a mathematical function that takes three independent parameters as input, however, it can also be solved (non-compactly) by specifying any two of the three.
Currently, I have the non-compact solution based strictly on a and b, with c as an optional constraint:
def func(a,b,c=None):
if c is not None:
# do something with a, b, and c
else:
# do something with only a, b
return result
However, I would like to be able to specify any two of a, b, or c, and still keep the option of specifying all three. What's the most Pythonic way of doing that?
**kwargsapproach?None, then pass them as keyword arguments.try: [do something with a, b, and c, and then in the except block look at what exception is thrown and decide how to proceed from there.