Skip to content

Instantly share code, notes, and snippets.

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 keenhenry/395c9e187cf0c706c8c9 to your computer and use it in GitHub Desktop.
Save keenhenry/395c9e187cf0c706c8c9 to your computer and use it in GitHub Desktop.
A small script to print out the Exception inheritance hierarchy. Useful for writing exception handling (Python 2.5+)
#!/usr/bin/env python
def classtree(cls, indent=0):
print '.' * indent, cls.__name__
for subcls in cls.__subclasses__():
classtree(subcls, indent + 3)
classtree(BaseException)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment