Writing to SdtErr

Michael Hudson mwh at python.net
Mon Oct 22 09:38:40 EDT 2001


"Mike Peat" <mike at unicorn-fs.com> writes:

> Can anyone tell me how to:
> 
> 1) Turn of the Python "Traceback" output, or make it less verbose?

sys.excepthook = something_else

> 2) Write (print) to the StdErr channel instead of StdOut?

print >> sys.stderr, "foo"

Both of these require a new-ish Python (not sure which release,
sorry).

An example of both:

>>> def eh(type, value, tb):
...     print >> sys.stderr, "Exception: ", type
...
>>> sys.excepthook = eh
>>> 1/0
Exception:  exceptions.ZeroDivisionError

Cheers,
M.

-- 
  I have long since given up dealing with people who hold idiotic
  opinions as if they had arrived at them through thinking about
  them.                                 -- Erik Naggum, comp.lang.lisp



More information about the Python-list mailing list