I have the following code. Because I opened the file in binary mode, what will be read into the variable "line". Is it
- Read until the occurrence of a new line character. Return and repeat
- Read until some internal buffer size OR new line character. Return and repeat
with open('filename', mode='rb') as f: for line in f: do_some_process(line)
The other answers suggested earlier do not answer this question. They talk about the differences between the modes but here the question is, suppose Im reading a text file in binary mode and I want to ensure that I read line by line i.e. read until the occurrence of a newline character. The 'b' mode seems to be doing this, but is this guaranteed to always happen? Does 'b' mode read data until the occurrence of a new line or till the buffere size ? Im trying to undertand how Python handles this under the wraps.