In the documentation for Python's input/output, it states under Reading and Writing Files:
https://docs.python.org/3.5/tutorial/inputoutput.html#methods-of-file-objects
"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."
Let's take the following code:
size = 1000
with open('file.txt', 'r') as f:
while True:
read_data = f.read(size)
if not read_data:
break
print(read_data) # outputs data in sizes equal to at most 1000 bytes
Here, size
is at most 1000 bytes. What determines "at most"?
Let's say we are parsing rows of structured data. Each row is 750 bytes. Would read "cut off" the next row, or stop at the \n
?