Skip to content

Instantly share code, notes, and snippets.

@snim2
Created February 11, 2012 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snim2/1804191 to your computer and use it in GitHub Desktop.
Save snim2/1804191 to your computer and use it in GitHub Desktop.
Exception example in Python
class MyExn(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return "MyExn raised with value " + str(self.value)
def example():
try:
raise MyExn(0)
except MyExn, e:
print e
if __name__ == '__main__':
example()
# results in: "MyExn raised with value 0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment