In the python and/or ipython interactive interpreter, how can I get name bound on the last unhandled exception? I.e. the equivalent of
>>> try:
... 1/0
... except Exception as potato:
... pass
...
>>> format(potato)
'integer division or modulo by zero'
Must be something like…
>>> 1/0
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: integer division or modulo by zero
>>> import sys
>>> potato = ???
You can use
sys.last_valuefor this: