Overriding traceback print_exc()?
Scott David Daniels
scott.daniels at acm.org
Tue Oct 31 21:38:54 EST 2006
draghuram at gmail.com wrote:
> I usually have a function like this:
>
> def get_excinfo_str():
> """return exception stack trace as a string"""
> (exc_type, exc_value, exc_traceback) = sys.exc_info()
The parens here can be skipped:
exc_type, exc_value, exc_traceback = sys.exc_info()
> formatted_excinfo = traceback.format_exception(exc_type, exc_value,
> exc_traceback)
> excinfo_str = "".join(formatted_excinfo)
> del exc_type
> del exc_value
> del exc_traceback
The three del lines above don't do anything (the return decrefs the locals).
> return(excinfo_str)
The parens here can be skipped as well:
return excinfo_str
--
--Scott David Daniels
scott.daniels at acm.org
More information about the Python-list
mailing list