Catching a traceback

Isaac To kkto at
Tue Jun 8 04:13:45 CEST 2004

>>>>> "Peter" == Peter Hansen <peter at> writes:

    Peter> EAS wrote:
    >> I'm wondering if there is any way to keep a program running when it
    >> runs into an error (using the 'try' structure) and print the
    >> traceback to the screen?

    Peter> You can, of course, catch any exception at any level and print
    Peter> tracebacks.  In fact, if this is really what you were focusing
    Peter> on, then the answer to your question might be "yes".  If you can
    Peter> write the code so that it does catch an exception at the right
    Peter> place to allow safe continuation, then you can certainly keep
    Peter> your program running, and many people use exceptions in exactly
    Peter> that way.

I think the OP's query is mainly about whether it is possible to print a
stack trace without crashing the whole program.


More information about the Python-list mailing list