Handling exceptions without try block in Python's interactive shell
-
21-08-2019 - |
Question
See the title of this question. I want to play with the exception raised in the last command. _
didn't help me. Is there anything like that?
Solution
Do this:
import sys
sys.exc_info()
It will give you information about the exception. It's a tuple containing the exception type, the exception instance and a traceback object.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow