I have a function that applies different data preprocessing based on a string argument and am confused on how that is usually done in python because of the lack of switch statements and want to avoid long elif chains.
One solution I found and used was something like:
def preprocessing_a(X,y):
...
return X
def preprocessing_b(X,y):
...
return X
...
def none(X,y):
return X
mode = {
"a" : preprocessing_a
"b" : preprocessing_b
...
"none": none
}
X = mode[input_mode_string](X,y)
I personally found this to seem really clean but got quite a bit of negative feedback for it because I capsuled functions so I wonder how big libraries or larger applications handle this type of input since it's used a lot.