output buffering

J

JD

Hello,

When reading a large datafile, I want to print a '.' to show the
progress. This fails, I get the series of '.'s after the data has been
read. Is there a trick to fix this?

Thanks
 
F

Fredrik Lundh

JD said:
When reading a large datafile, I want to print a '.' to show the
progress. This fails, I get the series of '.'s after the data has been
read. Is there a trick to fix this?

assuming that you're printing to stdout,

sys.stdout.flush()

should do the trick.

</F>
 
S

skip

jd> When reading a large datafile, I want to print a '.' to show the
jd> progress. This fails, I get the series of '.'s after the data has
jd> been read. Is there a trick to fix this?

As Fredrik indicated, you need to flush the output buffer. You might also
want to check out the progress module available from my Python Bits page:

http://orca.mojam.com/~skip/python/

Skip
 

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

No members online now.

Forum statistics

Threads
474,270
Messages
2,571,351
Members
48,036
Latest member
nickwillsonn

Latest Threads

Top