print to console without a line break

Qian Xu quian.xu at stud.tu-ilmenau.de
Tue Dec 23 12:06:09 CET 2008


Qian Xu wrote:

> Hello All,
> 
> Is it possible to print something to console without a line break?
> 
> I tried:
>   sys.stdout.write("Testing something ...") // nothing will be printed
>   time.sleep(1)
>   sys.stdout.write("done\n") // now, the whole string will be printed
> 
> What I want, is to see "Testing something ..." first.
> And after 1 second, to see "done" (with a line break)
> 

I have solved the problem by calling
  sys.stdout.flush()

--Qian Xu





More information about the Python-list mailing list