howto catch an Exception and still print the TraceBack?

Fabio Zadrozny fabioz at esss.com.br
Thu Feb 2 04:53:18 EST 2006


Saizan wrote:

>Thanks, I had completely missed the module traceback...
>I'll use traceback.print_exc(), it seems the most straightforward way.
>The only flaw is that the traceback starts in the method where i catch the exception and not from "__main__", but I guess it can't be helped.
>  
>
Actually, I guess that if you wanted to check the 'upper stack', you 
could do it by checking sys._getframe() to get the current frame and 
then go upwards with frame.f_back (that's how debbugers work), that way 
you could get info on all the stacks you currently have... so if you 
think it's worth it... ;-P

Cheers,

Fabio





More information about the Python-list mailing list