I have finished pset5 and now on pset6 but I have one doubt about how we can read the file without file.read() or readlines() etc.
I understand both code
file = open(“testfile.txt”, “r”)
c = file.read()
print(c)
OR
with open('file.txt') as fp:
lines = fp.read()
But how this can work, how can for
loop read file without reading
file = open(“testfile.txt”, “r”)
for line in file:
print(line)
Even David M uses for
meathod in week 8 lectures to port speller load function in python.
If this is features then how both are different?