Skip to content

Instantly share code, notes, and snippets.

@poros
Created October 7, 2015 09:18
Show Gist options
  • Save poros/beedc60f990386ad0484 to your computer and use it in GitHub Desktop.
Save poros/beedc60f990386ad0484 to your computer and use it in GitHub Desktop.
Follow a file like tail -f with generators
import time
def follow(thefile):
thefile.seek(0,2)
while True:
line = thefile.readline()
if not line:
time.sleep(0.1)
continue
yield line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment