Skip to content

Commit 6c588a0

Browse files
Correct info about "f.read(size)". (GH13852)
In text mode, the "size" parameter indicates the number of characters, not bytes. (cherry picked from commit faff81c) Co-authored-by: William Andrea <[email protected]>
1 parent d42a4fd commit 6c588a0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Doc/tutorial/inputoutput.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,8 @@ To read a file's contents, call ``f.read(size)``, which reads some quantity of
358358
data and returns it as a string (in text mode) or bytes object (in binary mode).
359359
*size* is an optional numeric argument. When *size* is omitted or negative, the
360360
entire contents of the file will be read and returned; it's your problem if the
361-
file is twice as large as your machine's memory. Otherwise, at most *size* bytes
362-
are read and returned.
361+
file is twice as large as your machine's memory. Otherwise, at most *size*
362+
characters (in text mode) or *size* bytes (in binary mode) are read and returned.
363363
If the end of the file has been reached, ``f.read()`` will return an empty
364364
string (``''``). ::
365365

0 commit comments

Comments
 (0)