I am new to Python and trying to learn the language structure.
I understand how for statement and open function work. But cannot explain how this piece of code works, which dumps the content of file sample_log.txt to screen:
for line in open("sample_log.txt"):
print line
These are my questions:
- Does
openreturn a list? - When the file actually gets read to memory?
- Does the file gets read line by line or all at once?