reading multiple files

Mag Gam magawake at gmail.com
Fri Sep 10 02:05:22 CEST 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