reading multiple files

Mag Gam magawake at gmail.com
Thu Sep 9 20:05:22 EDT 2010


I have 3 files which are constantly being updated therefore I use tail
-f /var/log/file1, tail -f /var/log/file2, and tail -f /var/log/file3

For 1 file I am able to manage by
tail -f /var/log/file1 | python prog.py

prog.py looks like this:
f=sys.stdin
for line in f:
  print line

But how can I get data from /var/log/file2 and /var/log/file3 ? I
prefer a native python way instead of doing tail -f

TIA



More information about the Python-list mailing list