]> granicus.if.org Git - python/commitdiff
Correct info about "f.read(size)". (GH13852)
authorWilliam Andrea <william.j.andrea@gmail.com>
Tue, 10 Sep 2019 14:50:26 +0000 (10:50 -0400)
committerBenjamin Peterson <benjamin@python.org>
Tue, 10 Sep 2019 14:50:26 +0000 (15:50 +0100)
In text mode, the "size" parameter indicates the number of characters, not bytes.

Doc/tutorial/inputoutput.rst

index fc2bd5578c4cf15581fd409b5e7ac954b6cf153f..9fe1276ec9d150dc2abd73d9af7e369d0904481e 100644 (file)
@@ -358,8 +358,8 @@ To read a file's contents, call ``f.read(size)``, which reads some quantity of
 data and returns it as a string (in text mode) or bytes object (in binary mode).
 *size* is an optional numeric argument.  When *size* is omitted or negative, the
 entire contents of the file will be read and returned; it's your problem if the
-file is twice as large as your machine's memory. Otherwise, at most *size* bytes
-are read and returned.
+file is twice as large as your machine's memory. Otherwise, at most *size*
+characters (in text mode) or *size* bytes (in binary mode) are read and returned.
 If the end of the file has been reached, ``f.read()`` will return an empty
 string (``''``).  ::