3

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?

1
  • Could you provide any code or error traceback or anything we can read to understand what you're talking about? Commented Jul 3, 2009 at 12:15

2 Answers 2

5

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.

Sign up to request clarification or add additional context in comments.

2 Comments

sys.last_value will not work in 3.0, sys.exc_info() will work on 3.0 and 2.x
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.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.