import time from watchdog.observers import Observer from watchdog.events import FileSystemEventHandler class Watcher: def __init__(self, path): self.path = path self.observer = Observer() self.observer.schedule(MyHandler(), path, recursive=True) self.observer.daemon = True def run(self): self.observer.start() try: while True: time.sleep(5) except KeyboardInterrupt: self.observer.stop() self.observer.join() class MyHandler(FileSystemEventHandler): def on_modified(self, event): print("File Changed:" + event.src_path) if __name__ == '__main__': w = Watcher('./watcher_folder') w.run()In this example, a simple class is defined to listen for any changes in the 'watcher_folder' folder. The Observer class is used to monitor the folder and any changes in the folder are notified to the MyHandler class, which in turn prints out the details of file changes. Package library: watchdog.