sys.stdout vs. sys.stderr

Nobody nobody at nowhere.com
Mon Jan 11 19:47:31 CET 2010


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. 




More information about the Python-list mailing list