I've got a string which will form a timedelta object based on its value. I could write this with if statements, but I know that the string will always match one of the named arguments for the timedelta object. I want to do something similar to below:
td = timedelta("hours"=5)
or:
my_var = "days"
td = timedelta(my_var=5)
What would be the recommended way to do this?