diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2014-10-01 19:37:42 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2014-10-01 19:37:42 (GMT) |
commit | 1895f2b544379476f23a45c0cfdeb6cec1221c96 (patch) | |
tree | e7ed9190a5671e03a5b9051424bdfcd8e37ae07e /Doc/library/functions.rst | |
parent | 0428e6cc8947e9f100d330789bd73f0dab513cdc (diff) | |
download | cpython-1895f2b544379476f23a45c0cfdeb6cec1221c96.zip cpython-1895f2b544379476f23a45c0cfdeb6cec1221c96.tar.gz cpython-1895f2b544379476f23a45c0cfdeb6cec1221c96.tar.bz2 |
Issue 22492: Be explicit that print does not support binary mode files.
Original patch by Georg Brandl.
Diffstat (limited to 'Doc/library/functions.rst')
-rw-r--r-- | Doc/library/functions.rst | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 2a89ce4..f7ae383 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1083,8 +1083,8 @@ are always available. They are listed here in alphabetical order. .. function:: print(*objects, sep=' ', end='\\n', file=sys.stdout, flush=False) - Print *objects* to the stream *file*, separated by *sep* and followed by - *end*. *sep*, *end* and *file*, if present, must be given as keyword + Print *objects* to the text stream *file*, separated by *sep* and followed + by *end*. *sep*, *end* and *file*, if present, must be given as keyword arguments. All non-keyword arguments are converted to strings like :func:`str` does and @@ -1094,9 +1094,12 @@ are always available. They are listed here in alphabetical order. *end*. The *file* argument must be an object with a ``write(string)`` method; if it - is not present or ``None``, :data:`sys.stdout` will be used. Whether output - is buffered is usually determined by *file*, but if the *flush* keyword - argument is true, the stream is forcibly flushed. + is not present or ``None``, :data:`sys.stdout` will be used. Since printed + arguments are converted to text strings, :func:`print` cannot be used with + binary mode file objects. For these, use ``file.write(...)`` instead. + + Whether output is buffered is usually determined by *file*, but if the + *flush* keyword argument is true, the stream is forcibly flushed. .. versionchanged:: 3.3 Added the *flush* keyword argument. |