2020-08-11 Debug, tracebackΒΆ

A trick I use sometimes to print the traceback without stopping the program.

<<<

import traceback

try:
    assert False
except AssertionError:
    tb = traceback.extract_stack()
    print()
    for line in tb:
        if ("tf2onnx" in line.filename and "site-packages" not in line.filename and
                'python3' not in line.filename):
            print('  File "{}", line {}'.format(line.filename, line.lineno))

>>>