sys.stdout .>_<.

Pierre Barbier de Reuille pierre.barbier at cirad.fr
Fri Nov 5 08:22:29 EST 2004


It's not possible !

stdout is usually a pipe ... and you cannot go back in a pipe ...
Try with any pipe you should have the same result.

The only way toi achieve this is to assume an ANSI terminal and to use 
ANSI codes to go back ("\r" to go at the beginning of the line "^h" to 
go back one char)

Leon a écrit :
> import os,sys
> a = os.fdopen(sys.stdout.fileno(),"w")
> b = os.fdopen(sys.stdout.fileno(),"w")
> a.write("test1 ")
> b.write("test2 ")
> 
> stdout result is
> 
> test1 test2
> 
> but use general file object such as...
> 
> a = open("test.txt","w")
> b = open("test.txt","w")
> a.write("test1")
> b.write("test2")
> 
> the "test.txt" file content is
> 
> test2
> 
> how to do this result to sys.stdout
> 
> 



More information about the Python-list mailing list