[Tutor] reassigning/replacing sys.stdout
cappy2112 at gmail.com
Tue Jan 30 09:22:13 CET 2007
I'm writing a python gui app that will call a python cmd line app. The gui
will take users input, pass it to the cmd line app, then display the cmd app
program output. The idea is to give users who aren't comfortable with the
cmd line a way to run the program, without having to open a shell window (on
Linux) or cmd prompt (On Windows) and get hung up on syntax or shell
issues. It's a crutch.
The author of the cmd line app suggested I temporarily replace
sys.stdout'with a file descriptor class that can write directly to the
The author is now out of communications for a few weeks, so I can't
However, I've opened a file which writes to the disk, and replaced that
sys.stdout with that file descriptor.
I can then close and open that file and have the output of his program.
Now I can just put this in a textbox on the gui and display it to the user.
Writing to a file on disk, then reading it back in seems a bit clunky to me.
While I did somewhat do what the author had suggested (although I didn't
make a class out of the file descriptor), and it works, is there a better
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor