python program to watch a file - example.

Isaac To kkto at
Sun Sep 8 16:21:50 CEST 2002

>>>>> "Tim" == Tim Hoffman <timh at> 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> stdin.

    Tim> ie tail -f somfile | python

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 mailing list