print to console without a line break

Qian Xu quian.xu at stud.tu-ilmenau.de
Tue Dec 23 05:50:59 EST 2008


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)

The only one solution I have found is to call "echo -n 'my_string'".
But it is not nice. Because I have to escape all special chars in the string
manually.

Any advice?
Best regards
-- Qian Xu



More information about the Python-list mailing list