Last active
August 29, 2015 14:00
-
-
Save bradmontgomery/11017222 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
$ python temp.py | |
in try | |
in exceptky |
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
try: | |
#print "in try, access a list item that doesn't exist:" | |
#values = range(2) | |
#print values[10000] | |
print 'after exit' | |
# some dictionary | |
d = {'a': 'A value', 'b': 'B value'} | |
print d['c'] | |
except IndexError: | |
# some code taht handles the IndexError | |
print("whoops! That index doesn't exist") | |
except KeyError: | |
# other error | |
print("some invalid key look in a dictiony") | |
except: # Usually considered bad practice | |
print "in except, before" | |
exit(1) | |
print 'after exit, after' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment