Re: (Python) Generator Tricks For Systems Programmer (pdf)
by plainOldText on Wednesday December 14, 2011 @04:40AM
(#3351237)
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
Implementation of "tail -f filename" in Python given as example. (slightly altered)
This is so cool.