Skip to content

Instantly share code, notes, and snippets.

@drupalista-br
Last active December 15, 2015 14:59
Show Gist options
  • Select an option

  • Save drupalista-br/5278910 to your computer and use it in GitHub Desktop.

Select an option

Save drupalista-br/5278910 to your computer and use it in GitHub Desktop.
options = { 'cow' : animal, 'cat' : animal, 'earth' : planet,
'venus' : planet, 'lettuce' : vegetable, 'apple' : fruit }
def animal():
print 'This is an animal'
def fruit():
print 'This is a fruit'
def vegetable():
print 'This is a vegetable'
def planet():
print 'This is a planet'
def defaultvalue():
print 'I dont know what that is'
options.get('cat', defaultvalue)()
# This is an animal
options.get('house', defaultvalue)()
# I dont know what that is
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment