Capturing exceptions?

Dfenestr8 chrisdewinN0SPAM at yahoo.com.au
Wed Aug 25 15:46:00 EDT 2004


On Wed, 25 Aug 2004 20:55:31 +0200, Mathias Waack 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:
>>>> 
>>>>>try:
>>>>>main()
>>>>>except:
>>>>>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?
> 
> Mathias

yep. Should do.

Thanx.

PS: Still would like to know what kind of parameter that other method
wants.




More information about the Python-list mailing list