output buffering

Discussion in 'Python' started by JD, Nov 11, 2005.

  1. JD

    JD Guest

    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
     
    JD, Nov 11, 2005
    #1
    1. Advertising

  2. "JD" <> wrote:

    > 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>
     
    Fredrik Lundh, Nov 11, 2005
    #2
    1. Advertising

  3. JD

    JD Guest

    On 2005-11-11, Fredrik Lundh <> wrote:
    > "JD" <> wrote:
    >
    >> 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.


    It does,

    Thanks!
     
    JD, Nov 11, 2005
    #3
  4. JD

    Guest

    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
     
    , Nov 11, 2005
    #4
  5. JD

    Larry Bates Guest

    This is something I wrote that might help.

    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/299207

    -Larry Bates

    JD wrote:
    > 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
     
    Larry Bates, Nov 11, 2005
    #5
  6. JD

    JD Guest

    On 2005-11-11, Larry Bates <> wrote:
    > This is something I wrote that might help.
    >
    > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/299207
    >


    The solutions become better and better.
    Thanks.

    > -Larry Bates
    >
    > JD wrote:
    >> 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
     
    JD, Nov 11, 2005
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tim Mohler
    Replies:
    1
    Views:
    461
    Steve Grazzini
    Sep 16, 2003
  2. =?Utf-8?B?U2NvdHRPbmVz?=

    Buffering the output of multiple controls

    =?Utf-8?B?U2NvdHRPbmVz?=, Oct 27, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    524
    =?Utf-8?B?a2Fub25lcw==?=
    Oct 28, 2004
  3. Mark Riordan
    Replies:
    6
    Views:
    4,948
    Mark Riordan
    Oct 15, 2004
  4. Shahid Juma

    Output Buffering

    Shahid Juma, Oct 5, 2004, in forum: ASP General
    Replies:
    1
    Views:
    154
    Ray Costanzo [MVP]
    Oct 5, 2004
  5. Joel VanderWerf
    Replies:
    3
    Views:
    157
    Joel VanderWerf
    Feb 14, 2004
Loading...

Share This Page