sys.stdout vs. sys.stderr

Discussion in 'Python' started by Mitchell L Model, Jan 11, 2010.

  1. In Python 3.1 is there any difference in the buffering behavior of the
    initial sys.stdout and sys.stderr streams? They are both line_buffered
    and stdout doesn't seem to use a larger-grain buffering, so they seem
    to be identical with respect to buffering. Were they different at some
    earlier point in Python's evolution?
    Mitchell L Model, Jan 11, 2010
    #1
    1. Advertising

  2. > In Python 3.1 is there any difference in the buffering behavior of the
    > initial sys.stdout and sys.stderr streams?


    No.

    > Were they different at some earlier point in Python's evolution?


    That depends on the operating system. These used to be whatever the
    C library set up as stdout and stderr. Typically, they were buffered
    in the same way.

    Regards,
    Martin
    Martin v. Loewis, Jan 11, 2010
    #2
    1. Advertising

  3. Mitchell L Model

    Nobody Guest

    On Mon, 11 Jan 2010 10:09:36 +0100, Martin v. Loewis wrote:

    >> In Python 3.1 is there any difference in the buffering behavior of the
    >> initial sys.stdout and sys.stderr streams?

    >
    > No.
    >
    >> Were they different at some earlier point in Python's evolution?

    >
    > That depends on the operating system. These used to be whatever the
    > C library set up as stdout and stderr. Typically, they were buffered
    > in the same way.


    On Unix, stdout will be line buffered if it is associated with a tty
    and fully buffered otherwise, while stderr is always unbuffered.

    On Windows, stdout and stderr are unbuffered if they refer to a character
    device, fully buffered otherwise (Windows doesn't have line buffering;
    setvbuf(_IOLBF) is equivalent to setvbuf(_IOFBF)).

    ANSI C says:

    As initially opened, the standard error stream is not fully buffered; the
    standard input and standard output streams are fully buffered if and only
    if the stream can be determined not to refer to an interactive device.
    Nobody, Jan 11, 2010
    #3
    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. Roman Neuhauser
    Replies:
    0
    Views:
    643
    Roman Neuhauser
    Apr 4, 2005
  2. GinTon

    sys.stderr.write and sys.exit

    GinTon, Nov 23, 2006, in forum: Python
    Replies:
    5
    Views:
    568
    Dennis Lee Bieber
    Nov 24, 2006
  3. Michel Albert
    Replies:
    5
    Views:
    1,352
    Daniel Dehennin
    Oct 24, 2012
  4. Geoff Bache
    Replies:
    4
    Views:
    530
  5. Jai
    Replies:
    1
    Views:
    146
    Neil Cerutti
    Nov 19, 2013
Loading...

Share This Page