Question

Should I prefer sys.exc_info() over sys.last_value and friends (sys.last_type, sys.last_traceback)?

Was it helpful?

Solution

Looking at the documentation of sys.last_value and friends:

Their intended use is to allow an interactive user to import a debugger module and engage in post-mortem debugging without having to re-execute the command that caused the error.

So, if you are in an interpreter doing debugging I suggest using sys.last_value, but in a script I suggest you to use sys.exc_info().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top