import traceback


def format_traceback_the_way_python_does(type, exc, tb):
    """
    Returns a traceback that looks like the one python gives you in the shell, e.g.

    Traceback (most recent call last):
      File "<stdin>", line 2, in <module>
    NameError: name 'name' is not defined
    """
    tb = ''.join(traceback.format_tb(tb))
    return f'Traceback (most recent call last):\n{tb}{type.__name__}: {exc}'