Newbie question

Thomas Guettler guettli at thomas-guettler.de
Fri Jul 23 07:29:10 EDT 2004


Am Fri, 23 Jul 2004 13:03:47 +0200 schrieb Harry Knitter:

> Hello,
> 
> I am new with Python and would like to know how to achieve to make a Python
> program continously  listening if a certain data file is changed from
> another program.
> Thanks

untested:

import os
import time

file="...."
mtime=os.path.getmtime(file)
while 1:
    if os.path.getmtime(file)!=mtime:
        print "%s changed" % file
        mtime=os.path.getmtime(file)
    time.sleep(1)

-- 
Thomas Güttler, http://www.thomas-guettler.de/





More information about the Python-list mailing list