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?
"JD" <jd@something.c om> wrote:
[color=blue]
> 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?[/color]
On 2005-11-11, Fredrik Lundh <fredrik@python ware.com> wrote:[color=blue]
> "JD" <jd@something.c om> wrote:
>[color=green]
>> 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?[/color]
>
> assuming that you're printing to stdout,
>
> sys.stdout.flus h()
>
> should do the trick.[/color]
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:
JD wrote:[color=blue]
> 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[/color]
The solutions become better and better.
Thanks.
[color=blue]
> -Larry Bates
>
> JD wrote:[color=green]
>> 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[/color][/color]
Comment