How to catch str exception?
Peter Otten
__peter__ at web.de
Fri May 15 05:46:57 EDT 2009
anuraguniyal at yahoo.com wrote:
> but the whole point of catching such exception is that i can print its
> value
> there are many such exceptions and hence it is not feasible to catch
> them all or know them all unless i go thru src code.
Catch them all with a bare except and then reraise non-string exceptions:
try:
raise "abc"
except:
e, t, tb = sys.exc_info()
if not isinstance(e, str):
raise
print "caught", e
More information about the Python-list
mailing list