python program to watch a file - example.
kkto at csis.hku.hk
Sun Sep 8 16:21:50 CEST 2002
>>>>> "Tim" == Tim Hoffman <timh at zute.net> writes:
Tim> If it is always the same file and seeing you are looking at *nix
Tim> varient, one of the unix like ways would be to tail -f the file,
Tim> and hook it up to your process which just does blocking reads on
Tim> ie tail -f somfile | python my_watch.py
tail -f is doing a polling loop, polling each second by default. In python
you are probably better off coding even the polling loop in Python as well,
rather than calling tail.
More information about the Python-list