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?
-
Could you provide any code or error traceback or anything we can read to understand what you're talking about?S.Lott– S.Lott2009-07-03 12:15:52 +00:00Commented Jul 3, 2009 at 12:15
Add a comment
|
2 Answers
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.
2 Comments
Anurag Uniyal
sys.last_value will not work in 3.0, sys.exc_info() will work on 3.0 and 2.x
jd.
sys.last_value works in 2.7 and according to the documentation, it's still there in Python 3.3. However sys.exc_info() won't work outside of an
except block.If your 'interactive' happens within Jupyter, check this > Jupyter magic to handle notebook exceptions
It is just beautiful.
If you want to add a sound > Jupyter / Colab : Play sound with any error in any cell + Play sound after completing long running cells