print without newline "halts" program execution

Karlo Lozovina _karlo_ at _mosor.net_
Thu Apr 13 20:57:18 EDT 2006


Consider this short script:

---
from time import time, sleep

st = time()
print 'Start: %f, ' % st,
sleep(10)
sp = time()
print 'Stop: %f, Duration: %f' % (sp, (st - sp))
---

On my environment (Linux, py24), when run, Python first waits 10s, and 
then produces the entire output. How, can I make it print first part 
('Start: %f, '), then wait 10s, and then append (WITHOUT NEWLINE) that 
second print statement?

I'm writting a script with lot of output which has to go on the same line, 
but I don't want to wait for it to end to see output, I just want it to 
print parts as it's finished with them.

Using sys.stdout.write() produces the same behavior, so what can I do?

Thanks a lot in advance.

-- 
 _______                                        Karlo Lozovina - Mosor
|   |   |.-----.-----.     web: http://www.mosor.net || ICQ#: 10667163
|       ||  _  |  _  |             Parce mihi domine quia Dalmata sum.
|__|_|__||_____|_____|



More information about the Python-list mailing list