Created
June 19, 2012 17:54
-
-
Save sdqali/2955562 to your computer and use it in GitHub Desktop.
This file contains 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
options = { | |
'init': init_journal, | |
'safekeep': safekeep, | |
'jot': jot | |
} | |
options.get(command, wrong_command)() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could just have have three functions called
init
,safekeep
andjot
and then simply saylocals()[command]()
to get your action handler. If your handlers were methods, it would be even nicer and you can callgetattr(object, command)()
.