Python exceptions: is there a way to find the exception attributes?
Pat Notz
pknotz at sandia.gov
Sat Nov 30 20:30:11 EST 2002
> Is there a way to find out about the existence of these attributes
> without having to read the documentation, using the dir() function or
> something else?
You can also cast the exception into a string which -- if the
exception class is properly designed -- should give you useful
information. For example:
try:
open('/foo.bar')
except Exception, e:
print 'Exception occurred: %s' % str(e)
That's not exactly what you were asking for but maybe it'll help.
More information about the Python-list
mailing list