Skip to content

Instantly share code, notes, and snippets.

@snim2
Created May 16, 2010 12:54
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/402861 to your computer and use it in GitHub Desktop.
Save snim2/402861 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
def listexns(mod):
module = __import__(mod)
exns = []
for name in module.__dict__:
if (isinstance(module.__dict__[name], Exception) or
name.endswith('Error')):
exns.append(name)
for name in exns:
print '%s.%s is an exception type' % (str(mod), name)
return
if __name__ == '__main__':
import sys
if len(sys.argv) <= 1:
print 'Give me a module name on the $PYTHONPATH!'
print 'Looking for exception types in module: %s' % sys.argv[1]
listexns(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment