I understand (in some minimal sense) that it is considered bad practice to read an entire text file as a string if you don't know the file size, or the file size is big. For example:
with open('letters.txt', 'r') as my_txt_file:
my_txt = my_txt_file.read()
would make my_txt
a string that consists of all the text in 'letters.txt'
.
I'm assuming that the threshold for considering a file as being too large to read as a string depends on the specifications of one's hardware. But I was wondering if, in general, is there a certain file size limit when one should opt for reading a file line-by-line?