Im having trouble understanding clean way to do this. I would like a function named set_delay()
that take a variety of parameters. I have 3 different "delay types" that can be set: constant, uniform, and normal. Here is what I currently have:
def set_delay_constant(delay):
continue
def set_delay_uniform(min_delay, max_delay):
continue
def set_delay_normal(mean, std_dev, timeout):
continue
The problem I have with the above is that about ~80% of the code in each function is repeated. Ideas Ive seen are:
def set_delay(delay_type, delay=None, min_delay=None, max_delay=None, mean=None, std_dev=None, timeout=None):
continue
But when I need to extend this with more delay types, I can see this getting very long and hard to read. What is the most "pythonic" way to go about this? Thank you!