Watching TXT file updates through Python

57 Views Asked by At

I'm working on a python program that should wait for another program to update a .txt file, and when the file was updated my program should open it, get the command the other program just made, and then run something else. I'm quite new to python so a generic but well-explained solution would be great.

I've found How do I watch a file for changes? that leads to the solution here, but I can't quite understand how this works. The program could also be in other languages but it should trigger my python modules.

Here's the general idea of what I'm looking for.

sub GET_FILE_UPDATE:  
try:  
    while change == False:  
       time.sleep(1)  
    else  
       if change == True  
       'open file and read command'  
       run.command()  
    except KeyboardInterrupt:  
       'stop program'
0

There are 0 best solutions below