Skip to content

Instantly share code, notes, and snippets.

@bradmontgomery
Last active August 29, 2015 14:00
Show Gist options
  • Save bradmontgomery/11017222 to your computer and use it in GitHub Desktop.
Save bradmontgomery/11017222 to your computer and use it in GitHub Desktop.
$ python temp.py
in try
in exceptky
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