[Python-ideas] Replacing the standard IO streams (was Re: changing sys.stdout encoding)

Rurpy rurpy at yahoo.com
Sun Jun 10 06:22:03 CEST 2012

On 06/09/2012 08:26 PM, Nick Coghlan wrote:
> Calling detach() on the standard streams is a bad idea - the
> interpreter uses the originals internally, and calling detach()
> breaks them.

The documentation for sys.std* specifically describes
using detach() on the standard streams:

| To write or read binary data from/to the standard
| streams, use the underlying binary buffer.

and gives example code.

The only caveat mentioned is that detach() "can raise
AttributeError or io.UnsupportedOperation" if the stream
has benn replaced with something that does not support

More information about the Python-ideas mailing list