Skip to content

Comment on (Python) Generator Tricks For Systems Programmer (pdf)

Comments

I've really enjoyed this presentation. Thanks for sharing

Implementation of "tail -f filename" in Python given as example. (slightly altered)

  def follow(filename):
       f = open(filename)
       f.seek(0,2)
       while True:
           line = f.readline()
           if not line:
               continue
           yield line

  for new_line in follow('/tmp/test.file'):
       print new_line
This is so cool.
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.