output buffering--am I missing something obvious?

Andrew Koenig ark at research.att.com
Fri Apr 4 16:02:46 EST 2003


Can someone please explain the following behavior?  Under Python 2.2.2
and Solaris 2.8:

    >>> import sys
    >>> sys.stdout.write("foo")
    >>> sys.stdout.flush()
    >>> sys.stdout.write("bar\n")
    bar

I would have expected the call to sys.stdout.write to put "foo" into
the output buffer, and perhaps to have written it to the standard
output stream.  If the call to sys.stdout.write didn't write it, I
would have expected the call to sys.stdout.flush to have done so.

What I don't understand at all is how the second call to
sys.stdout.write should be able to write its output on the
standard output stream without the output from the first call
ever appearing.

What am I missing?

-- 
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark




More information about the Python-list mailing list