I have a situation where I have six possible situations which can relate to four different results. Instead of using an extended if/else statement, I was wondering if it would be more pythonic to use a dictionary to call the functions that I would call inside the if/else as a replacement for a switch statement, like one might use in C# or php.My switch statement depends on two values which I'm using to build a tuple, which I'll in turn use as the key to the dictionary that will function as my switch. I will be getting the values for the tuple from two other functions (database calls), which is why I have the example one() and zero() functions.This is the code pattern I'm thinking of using which I stumbled on with playing around in the python shell:def one():    #Simulated database value    return 1def zero():    return 0def run():    #Shows the correct function ran    print RUN    return 1def walk():    print WALK    return 1def main():    switch_dictionary = {}    #These are the values that I will want to use to decide    #which functions to use    switch_dictionary[(0,0)] = run    switch_dictionary[(1,1)] = walk    #These are the tuples that I will build from the database    zero_tuple = (zero(), zero())    one_tuple = (one(), one())    #These actually run the functions. In practice I will simply     #have the one tuple which is dependent on the database information    #to run the function that I defined before    switch_dictionary[zero_tuple]()    switch_dictionary[one_tuple]()I don't have the actual code written or I would post it here, as I would like to know if this method is considered a python best practice. I'm still a python learner in university, and if this is a method that's a bad habit, then I would like to kick it now before I get out into the real world.Note, the result of executing the code above is as expected, simply RUN and WALK.
Is this a pythonic method of executing functions based on the values of a tuple?
python
In short, a dictionary of functions IS the Python equivalent of the switch statement.However, your implementation is awful. Start by dropping the switch in your variable names. It is not a switch, it is a dictionary. And there is no point in using dictionary in the name either. Make a real name like act_on_msg but even that is weak in my opinion.And don't even explain that you are using a dictionary as a switch in your comments. At most, mention that  actOnMsg[combomsg]() runs the action method just to help those who are not used to seeing parentheses in that context.