Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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