Capturing exceptions?

Mathias Waack M.Waack at
Wed Aug 25 20:55:31 CEST 2004

Dfenestr8 wrote:

> On Wed, 25 Aug 2004 19:19:06 +0200, Mathias Waack wrote:
>> Dfenestr8 wrote:
>>> What's the easiest way to capture the traceback from an
>>> exception, and write it to a file? Ideally, I'd like to be able
>>> to do something like:
>>>>write the traceback to a file
>> Have a look at the traceback module.
>> Mathias
> I did. Thanx. But I'm afraid I don't understand it.

import traceback
try: raise Exception, "python is so cool;)"
except: traceback.print_exc(None,file("exc.trc","w"))

Does it that what you want?


More information about the Python-list mailing list