core

a reverse_tb jupyer magic

source

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.


source

reverse_tb_on

 reverse_tb_on ()

source

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.


source

reverse_tb

 reverse_tb (line, cell)

A cell magic that reverses only the frames of the traceback of an error.

Tests

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']
foo()
Exception: 
foo()
Exception: 

Export