Created
February 3, 2022 07:51
-
-
Save vjayajv/ee6f2ca16a786f8221b104543e954eeb to your computer and use it in GitHub Desktop.
Switch Case using a JSON map in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def foo(bla): | |
print(str(bla)+" from foo method") | |
# your statements | |
def bar(bla): | |
print(str(bla)+" from bar method") | |
# your statements | |
action_map = { | |
"dofoo": foo, | |
"dobar": bar | |
} | |
action_one = "dofoo" | |
action_two = "dobar" | |
# let's call foo | |
action_map[action_one]("some bla") | |
# let's call bar | |
action_map[action_two]("some bla") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment