views:

41

answers:

2

Hello,

I want to execute one funtion each time a file gets written with new data (gets modified) and I'm using Python.

How can I do it?

Thanks in advance! :)

+2  A: 

I'm assuming that it's not necessarily your Python program that's modifying the file. I don't know if there's an OS-independent method. On Linux you can use pyinotify.

Artelius
+4  A: 

If you want to monitor for changes in the file system using Python, see this article for pointers to libraries which can help you achieve this on different platforms.

Short summary of available libraries for different platforms:

Remember that your program needs to be running to handle file system events.

Håvard S