Catching Errors

mixo mixo77 at usa.net
Fri Jun 8 10:25:06 EDT 2001


How can I  catch errors that I are usually written to standard output?
For example , say I have an error in my code, I  would like to to have
the ouput written to a file.. The following  is what is written to
standard output :
-------------------------------------------------
  Traceback (innermost last):
  File "errors-catch.py", line 24, in ?
    print "hello world!  s" %test
TypeError: not all arguments converted
-----------------------------------------------
due to the error in the statement :
    print "hello world!  s" %test # "s" should be "%s"

The idea is, I want to simply write it (the error )to a file !
(and I would n't mind as well  knowing what the errors is-
even if its just an error  code)





More information about the Python-list mailing list