console output delay

D

Dominik Kaspar

hello, my question concerns the following code fragment:

print "searching for bla bla...",
[long calculation]
print "found", numberofblablas

when this program is running, the "please be patient message" is not
displayed until the long calculation has actually completed.
is there any way to force the first print statement to be shown on the
console?

dominik
 
P

Peter Hansen

Dominik said:
hello, my question concerns the following code fragment:

print "searching for bla bla...",
[long calculation]
print "found", numberofblablas

when this program is running, the "please be patient message" is not
displayed until the long calculation has actually completed.
is there any way to force the first print statement to be shown on the
console?

sys.stdout.flush() ?

Alternatively you may find "python -u" to be of help. Using "python -h"
to learn more.

-Peter
 
T

Terry Reedy

Dominik Kaspar said:
hello, my question concerns the following code fragment:

print "searching for bla bla...",
[long calculation]
print "found", numberofblablas

when this program is running, the "please be patient message" is not
displayed until the long calculation has actually completed.
is there any way to force the first print statement to be shown on the
console?

did you try leaving off the comma on the first line?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,269
Messages
2,571,338
Members
48,029
Latest member
Anchorman2022

Latest Threads

Top