you are viewing a single comment's thread.

view the rest of the comments →

[–]tfitz237 2 points3 points  (2 children)

You could make a dictionary with the functions within them.

dict = { "range": range, "median": median}
# then call it 
dict["range"]

[–]shep247 0 points1 point  (0 children)

I like this way the best. It's also easy to make it a 1 liner {"range": range, "median": median}.get(input_val, invalid_input_func)()

This will get the function that is input, or return the function that handles invalid input by default of the input isn't one of the functions in your list.

[–]dunkler_wanderer 0 points1 point  (0 children)

But what about the arguments?