sys.stdout.write() question

Gian Mario Tagliaretti liquid at kuht.it
Mon Jun 21 15:04:04 CEST 2004


Hi all,

It is (I hope) a simple question,
I cannot figure out why sys.stdout.write() doesn't print immediatly the first 
text in the small example below, but before it process the code in between 
and then print both lines in one time.

#!/usr/bin/env python
import sys, time
sys.stdout.write('write ')
time.sleep(3)
sys.stdout.write('this\n')

if you try to run this, before it will wait 3 seconds and then print "write 
this" in one time.

If I put \n here :

sys.stdout.write('write \n')

it work properly but I would like to print the text in one row.

thanks to all
Mario




More information about the Python-list mailing list