Q: A Catch-all Exception-Handler
Andrew M. Kuchling
akuchlin at cnri.reston.va.us
Fri May 7 14:25:06 EDT 1999
Norbert.Klamann at pobox.com writes:
>The scripts print to stdout and in case of an exceptional exception I would
>like to see a traceback on Stdout.
One alternative is to do the required shell redirections to
capture both stderr and stdout, using >& or whatever. Or, you can
simply set stderr and stdout to be the same in your Python code.
import sys
sys.stderr = sys.stdout
C libraries that do fprintf(stderr, ...) will still print to the
original stdout, but Python code and tracebacks will go to the right place.
--
A.M. Kuchling http://starship.python.net/crew/amk/
This is a work of fiction. All the characters in it, human and otherwise, are
imaginary, excepting only certain of the fairy folk, whom it might be unwise
to offend by casting doubts on their existence. Or lack thereof.
-- Neil Gaiman, _Books of Magic_ III
More information about the Python-list
mailing list