Dispatch Tables in Python
https://medium.com/@andreacolangelo/dispatch-tables-in-python-d37bcc443b0b
Andrea ColangeloBlockedUnblockFollowFollowingDec 23Photo by Chris Ried on UnsplashHave you ever needed to run different functions according to the value of a variable? This first approach that comes to mind would probably be a long series of if-elif statements resembling a C-style switch case. Well, there is a better option: a dispatch table.
A dispatch table in Python is basically a dictionary of functions. This concept is not Python-specific indeed, rather quite common in Computer Science: