def foo():
return bar()
def bar():
return baz()
def baz():
try:
qux()except KeyError as e:
raise Exception
return qux()
def qux():
= {}
d return d['key']
core
a reverse_tb jupyer magic
AutoFormattedReversedTB
AutoFormattedReversedTB (*args:Any, **kwargs:Any)
A Traceback printer that reverse the order of the traceback, so that the most recent call is first.
Functions to globaly reverse or not all the tracebacks printed in the notebook.
reverse_tb_on
reverse_tb_on ()
reverse_tb_off
reverse_tb_off ()
A context manager will not reverse the traceback on its own because jupyter will exectue the cell, go to the finally
statement and then print the traceback. So the context manager will not be able to reverse the traceback.
But, together with the reverse_tb
magic, it will work.
reverse_tb
reverse_tb (line, cell)
A cell magic that reverses only the frames of the traceback of an error.
Tests
foo()
Exception:
foo()
Exception: