I have a small fastapi application that can get 4 optional arguments from the user, and based on the user's input run a matching function like so:
def do_function(origin, destination, departure, arrival):
if departure is None and arrival is None:
do_a(origin, destination)
elif departure is not None and arrival is None:
do_b(origin, destination, departure)
elif departure is None and arrival is not None:
do_c(origin, destination, arrival)
elif departure is not None and arrival is not None:
do_d(origin, departure, arrival)
elif departure is not None and arrival is None:
do_e(origin, departure)
# and so on...
What is the most pythonic way of executing this code without using long and tiering "if-elif"?
I've seen a similar question here: most efficient way to selection specific function based on input , but it doesn't apply to my case where there are only 4 optional inputs and more than 4 function options.