code: def follow(the_file):
      
      with open(the_file) as f:
          f.seek(0, 2)  # seek to eof
          while True:
              line = f.readline()
              if not line:
                  time.sleep(0.1)  # sleep briefly before trying again
                  continue
              yield line
docs: Follow a given file and yield new lines when they are available, like `tail -f`.