Tailing a File • A Python version of 'tail -f'
thefile.seek(0, os.SEEK_END) # End-of-file
line = thefile.readline()
if not line:
time.sleep(0.1) # Sleep briefly
• Idea : Seek to the end of the file and repeatedly try to read new lines. If new data is written to the file, we'll pick it up.
Copyright (C) 2018, http://www.dabeaz.com
Example File: follow.py