Switch-case statement in Python

Python doesn't have a switch/case statement because of Unsatisfactory Proposals . Nobody has been able to suggest an implementation that works well with Python's syntax and established coding style. There have been many proposals, some of which you can see in PEP 3103 -- A Switch/Case Statement . Most programming languages have switch/case because they don't have proper mapping constructs. You cannot map a value to a function, that's why they have it. But in Python, you can easily have a mapping table(dict) where a certain value maps to a certain function. Python functions are first class values, you can use the functions as the values of the dictionary get(key[, default]) method. Performance-wise, the Python dictionary lookup will almost certainly be more efficient than any solution you can rig yourself.
def fnc(x): return { 'one': 1, 'two': 2, }.get(x, 5) # 5 is default if x not found

In the example above, instead of values 1, 2 you can have functions, classes, lists, dicts absolutely anything you want.

def east(): return "East" def west(): return "West" def north(): return "North" def south(): return "South" # map the inputs to the function blocks switch_case = { 1 : east, 2 : west, 3 : north, 4 : south } print(switch_case[2]())