The readlines method on file object reads the entire content as a list of lines. Since the list is iterated over only once, we can get the exact same outcome by iterating over the file object directly. That will also yield the lines one by one, but without waiting for the entire file to be read.
The
readlines
method on file object reads the entire content as a list of lines. Since the list is iterated over only once, we can get the exact same outcome by iterating over the file object directly. That will also yield the lines one by one, but without waiting for the entire file to be read.