How can I 'follow' a file similar to the tail command from within python? For example, I though t the following would work:
def tail(filepath):
source = open(filepath)
source.seek(0,2)
while True:
chunk = source.readline()
yield chunk
source.close()
However, it doesn't seem to pick up on 'new lines' after it seems to the end, when those lines are added and saved to the file in question. What would be the correct way to tail a file in python?