Search code examples
pythonfilefunctionexecute

How to execute some code when a file is modified using python?


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?


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.