How to streamingly read text file and display whenever updated text

Joost Molenaar j.j.molenaar at gmail.com
Sat Oct 5 07:02:05 EDT 2013


A bit of googling found me this:
http://www.linux-support.com/cms/implementation-of-tail-in-python/

import time
import sys

def tail_f(file):
  interval = 1.0
  while True:
    where = file.tell()
    line = file.readline()
    if not line:
      time.sleep(interval)
      file.seek(where)
    else:
      yield line



More information about the Python-list mailing list