Consider the following Python script :
import time
f = open('data.txt')
while True :
line = next(f)
if line : print(line)
time.sleep(1)
Now assume that when this code starts executing, data.txt
contains only 5 physical lines. But this file data.txt
is getting appended with more lines dynamically.
Is there some way that I can read the new lines that are getting appended to data.txt
.
My observation is that the text read is the text existing in data.txt
at the time open
is performed.