Should I prefer sys.exc_info()
over sys.last_value
and friends (sys.last_type
, sys.last_traceback
)?
Asked
Active
Viewed 496 times
2

Matt Joiner
- 112,946
- 110
- 377
- 526
1 Answers
4
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()
.

orlp
- 112,504
- 36
- 218
- 315