[Python] Extract traceback info from an exception object

Discussão em 'Python' iniciado por Stack, Julho 9, 2025.

  1. Stack

    Stack Membro Participativo

    Given an Exception object (of unknown origin) is there way to obtain its traceback? I have code like this:

    def stuff():
    try:
    .....
    return useful
    except Exception as e:
    return e

    result = stuff()
    if isinstance(result, Exception):
    result.traceback <-- How?


    How can I extract the traceback from the Exception object once I have it?

    Continue reading...

Compartilhe esta Página