question for sys.stdout
Pierre Barbier de Reuille
pierre.barbier at cirad.fr
Thu Nov 4 09:48:01 CET 2004
If you want to "rewrite" a "stdout" object, just write a file-like
object and replace sys.stdout !
Then don't care about the old stdout anymore ... it's a pipe and it
won't bother you anymore :)
Another way to do so is the "C" way ... ie. using os.dup2. The advantage
of the "dup2" method is the replacement of the stdout of the whole
program (so, if you use external functions writing in stdout it will
work), but the drawback is you need to have a real file (ie. file, pipe,
Depends on what you want to use :)
Leon a écrit :
> "stdout" is file object, it open mode is "w"
> and it have a close() fuction.....
> while it run close(), how to reopen it
> because I want to do rewrite it
> stdout content update
More information about the Python-list