Last active
December 15, 2015 14:59
-
-
Save drupalista-br/5278910 to your computer and use it in GitHub Desktop.
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
| 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