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 <b...@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@python.org
> https://mail.python.org/mailman/listinfo/tkinter-discuss
>
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to