output buffering

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JD

    #1

    output buffering


    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
  • Fredrik Lundh

    #2
    Re: output buffering

    "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]

    assuming that you're printing to stdout,

    sys.stdout.flus h()

    should do the trick.

    </F>



    Comment

    • JD

      #3
      Re: output buffering

      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]

      It does,

      Thanks!

      Comment

      • skip@pobox.com

        #4
        Re: output buffering


        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:



        Skip

        Comment

        • Larry Bates

          #5
          Re: output buffering

          This is something I wrote that might help.



          -Larry Bates

          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]

          Comment

          • JD

            #6
            Re: output buffering

            On 2005-11-11, Larry Bates <larry.bates@we bsafe.com> wrote:[color=blue]
            > This is something I wrote that might help.
            >
            > http://aspn.activestate.com/ASPN/Coo.../Recipe/299207
            >[/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

            Working...