views:

115

answers:

1

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?

+4  A: 

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.

Lennart Regebro
Thanks, also `sys.last_value` works. :)
Achimnol
sys.last_value will not work in 3.0, sys.exc_info() will work on 3.0 and 2.x
Anurag Uniyal