Exercise 2: FileWatcher Distinguishing Between Two Real Files — Possible Solution ==================================================================== THE SETUP ------------------------------ file_a = 'watch_multi_test/a.html' # real file, written with 'a v1' file_b = 'watch_multi_test/b.html' # real file, written with 'b v1' watcher = FileWatcher([file_a, file_b]) VERIFIED, REAL RESULTS ------------------------------ watcher.changed() # None -- nothing edited yet # edit ONLY file_a (write 'a v2') watcher.changed() # file_a's own real path watcher.changed() == file_a # True watcher.changed() # None again -- already consumed # edit ONLY file_b (write 'b v2') watcher.changed() # file_b's own real path watcher.changed() == file_b # True WHY THIS WORKS AS AN ANSWER ------------------------------ FileWatcher.changed() loops over self.paths in order and returns the first path whose real, freshly-read mtime differs from what was stored, updating that one entry in self._mtimes before returning - file_b's own stored mtime is never touched while only file_a has changed, so it correctly stays silent about file_b until file_b is genuinely edited too. Verifying both files independently, with a "nothing changed" check in between, confirms the watcher tracks each real file's own state separately rather than collapsing "something changed" into one shared flag.