Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit faff81c

Browse files
wjandreabenjaminp
authored andcommitted
Correct info about "f.read(size)". (GH13852)
In text mode, the "size" parameter indicates the number of characters, not bytes.
1 parent 0518451 commit faff81c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

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)