sys.exc_info
Steven D'Aprano
steve at pearwood.info
Thu Jun 29 02:50:19 EDT 2017
sys.exc_info() returns three items:
(exception type, exception value, traceback)
https://docs.python.org/2/library/sys.html#sys.exc_info
https://docs.python.org/3/library/sys.html#sys.exc_info
and may be used something like this example:
try:
something
except:
exc_type, exc, tb = sys.exc_info()
print(traceback.extract_tb(tb))
raise
Why does it return the exception type separately from the exception, when
the type can be derived by calling `type(exc)`?
--
Steve
More information about the Python-list
mailing list