The global variable (in module sys) sys.exc_type contains the
exception type. For completeness, sys.exc_value contains the
exception value (same as msg), sys.exc_traceback contains the
traceback object. These three variables are given a value whenever an
except clause catches an exception.
When an exception is not handled and the interactive Python command
prompt (">>> ") is printed, the exception information is stored in
three other variables: sys.last_type, sys.last_value and
sys.last_traceback.
--Guido van Rossum, CWI, Amsterdam <mailto:Guido.van.Rossum@cwi.nl>
<http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>