file.read Method Documentation (Python 2.7.10)
Chris Angelico
rosuav at gmail.com
Wed Jan 11 06:00:21 EST 2023
On Wed, 11 Jan 2023 at 21:31, Stephen Tucker <stephen_tucker at sil.org> wrote:
>
> Chris -
>
> In the Python 2.7.10 documentation, I am referring to section 5. Built-in Types, subsection 5.9 File Objects.
>
> In that subsection, I have the following paragraph:
>
> file.read([size])
>
> Read at most size bytes from the file (less if the read hits EOF before obtaining size bytes). If the size argument is negative or omitted, read all data until EOF is reached. The bytes are returned as a string object. An empty string is returned when EOF is encountered immediately. (For certain files, like ttys, it makes sense to continue reading after an EOF is hit.) Note that this method may call the underlying C function fread() more than once in an effort to acquire as close to size bytes as possible. Also note that when in non-blocking mode, less data than was requested may be returned, even if no size parameter was given.
>
Yes, so it should be that number of bytes, which is what it does, isn't it?
ChrisA
More information about the Python-list
mailing list