From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Tue, 10 Sep 2019 16:02:40 +0000 (-0700) Subject: Correct info about "f.read(size)". (GH13852) X-Git-Tag: v3.7.5rc1~98 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=075a441fa0c900802e331167f617058c7d3a9607;p=thirdparty%2FPython%2Fcpython.git Correct info about "f.read(size)". (GH13852) In text mode, the "size" parameter indicates the number of characters, not bytes. (cherry picked from commit faff81c05f838b0b7a64bbc8c53c02a9b04bb79d) Co-authored-by: William Andrea --- diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst index 79427860f518..1dc01e82102d 100644 --- a/Doc/tutorial/inputoutput.rst +++ b/Doc/tutorial/inputoutput.rst @@ -356,8 +356,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 (``''``). ::