Question

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

How can I do it?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top