Skip to content

Instantly share code, notes, and snippets.

@poros
Created October 6, 2015 01:02
Show Gist options
  • Save poros/ec3e4658d74b78a3804d to your computer and use it in GitHub Desktop.
Save poros/ec3e4658d74b78a3804d to your computer and use it in GitHub Desktop.
Dictionary of callbacks or constructors
menu = {
'square': lambda x: x * x,
'cube': lambda x: x * x * x,
'half': lambda x: x / 2,
'double': lambda x: x * 2,
}
command = raw_input()
menu[command](4)
# with classes
commands = {
'run': RunCommand,
'kill': StopCommand,
'status': StatusCommand,
}
commands[cmd](**options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment