[Tkinter-discuss] Tracebacks

Michael O'Donnell michael.odonnell at uam.es
Sat Mar 1 13:05:10 CET 2014


Hi Bob,

  When my program starts up, I run:

 outstr=codecs.open(logfile, "w", 'utf-8')
 sys.stderr = outstr
 sys.stdout = outstr

That should do what you want.
The stream will close when the program closes.
Takes stderr AND normal print, but you could
drop the line for stdout

mick


On 28 February 2014 16:33, Bob Greschke <bob at passcal.nmt.edu> wrote:

> This isn't quite a Tkinter thing, but why can't some clever person (I
> couldn't do it) make it possible for you to put something like this
>
> #! /usr/bin/python -t "/home/me/error.txt",stderr
>
> at the beginning of a Python program and have the interpreter direct all
> of the traceback messages to the file error.txt, and stderr?  I've got a
> 43,000 line Tkinter/via X11 program and stupid users that won't tell me
> when it crashes -- if they even notice.  Right now we create an xterm on
> their computer then execute and ssh to the server where the program
> resides.  The errors come out in that xterm, but if the users quit they are
> gone.  It seems like the interpreter would be the smartest place to put
> something like this since it controls everything, and so you don't have to
> try and guess in which section of code you misspelled a variable name and
> put it in a try-except.
>
> Isn't this reasonable?  There are all kinds of questions about this
> problem, but never any really good solutions.  I like this one. :)  I just
> wouldn't have any idea how to do it, or if it's even possible.
>
> Bob
>
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
> https://mail.python.org/mailman/listinfo/tkinter-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20140301/21311a2d/attachment.html>


More information about the Tkinter-discuss mailing list