How to flush print

Discussion in 'Python' started by Jay Davis, Mar 6, 2004.

  1. Jay Davis

    Jay Davis Guest

    If you open a file the usual way, you can flush
    the output buffer with .flush(). How do you flush
    the output buffer of a print command, either
    'print string' or 'print >>ofile, string' ?
     
    Jay Davis, Mar 6, 2004
    #1
    1. Advertising

  2. Jay Davis

    Gerrit Guest

    Jay Davis wrote:
    > If you open a file the usual way, you can flush
    > the output buffer with .flush(). How do you flush
    > the output buffer of a print command, either
    > 'print string' or 'print >>ofile, string' ?


    print string

    is really short for

    sys.stdout.write("%s" % string)

    so you can flush it with

    sys.stdout.flush()

    Gerrit.
    --
    Weather in Amsterdam Airport Schiphol, Netherlands 07/03 08:55 UTC:
    6.0°C Few clouds partly cloudy wind 3.1 m/s W (-2 m above NAP)
    --
    Asperger's Syndrome - a personal approach:
    http://people.nl.linux.org/~gerrit/english/
     
    Gerrit, Mar 7, 2004
    #2
    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. Marina

    Re: Response.Flush() in code-behind

    Marina, Jul 1, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    457
    William F. Robertson, Jr.
    Jul 1, 2003
  2. William F. Robertson, Jr.

    Re: Response.Flush() does not work

    William F. Robertson, Jr., Aug 5, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    512
    William F. Robertson, Jr.
    Aug 5, 2003
  3. keto
    Replies:
    0
    Views:
    1,001
  4. David Cournapeau

    print a vs print '%s' % a vs print '%f' a

    David Cournapeau, Dec 30, 2008, in forum: Python
    Replies:
    0
    Views:
    374
    David Cournapeau
    Dec 30, 2008
  5. T. Onoma
    Replies:
    1
    Views:
    118
    Robert Klemme
    Nov 12, 2003
Loading...

Share This Page