diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-05-12 20:47:57 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-05-12 20:47:57 (GMT) |
commit | 4199d603fed4ea5aadb8c77fa118e3ea948fd109 (patch) | |
tree | 730e54f7a2cc9c89b4b59dd16d55f9f1fbd8d4f9 | |
parent | 57512588fa4178860d6f10175d75a672e8c396c2 (diff) | |
download | cpython-4199d603fed4ea5aadb8c77fa118e3ea948fd109.zip cpython-4199d603fed4ea5aadb8c77fa118e3ea948fd109.tar.gz cpython-4199d603fed4ea5aadb8c77fa118e3ea948fd109.tar.bz2 |
add example function
-rw-r--r-- | Doc/library/sys.rst | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 0d92170..ddd7e64 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -784,7 +784,13 @@ always available. The standard streams are in text mode by default. To write or read binary data to these, use the underlying binary buffer. For example, to write bytes to :data:`stdout`, use ``sys.stdout.buffer.write(b'abc')``. Using - :meth:`io.TextIOWrapper.detach` streams can be made binary by default. + :meth:`io.TextIOWrapper.detach` streams can be made binary by default. For + example, this function sets all the standard streams to binary: :: + + def make_streams_binary(): + sys.stdin = sys.stdin.detach() + sys.stdout = sys.stout.detach() + sys.stderr = sys.stderr.detach() .. data:: __stdin__ |