Created
August 20, 2014 10:59
-
-
Save swdream/e8b1d38446edf54766e0 to your computer and use it in GitHub Desktop.
simulate tail -f command line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def tail_F(filename): | |
p = 0 | |
with open(filename, 'r') as f: | |
while True: | |
f.seek(p) | |
new_line = f.read() | |
p = f.tell() | |
if new_line: | |
print new_line | |
print str(p).center(10).center(80, '=') | |
if __name__ == '__main__': | |
filename = 'whileloop.py' | |
tail_F(filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@hvnsweeting blabla