Does the Python read() method behave like C's read? Might it return less than the requested number of bytes before the last chunk of the file is reached? Or does it guarantee to always return the full amount of bytes when those bytes exist to be read?
Well, the Python Standard library says this about 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. ... An empty string is returned when EOF is encountered immediately. ... Also note that when in non-blocking mode, less data than was requested may be returned, even if no size parameter was given.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With