As noted, you can use pyinotify:
E.g.:
import webbrowser
import pyinotify
class ModHandler(pyinotify.ProcessEvent):
# evt has useful properties, including pathname
def process_IN_CLOSE_WRITE(self, evt):
webbrowser.open(URL)
handler = ModHandler()
wm = pyinotify.WatchManager()
notifier = pyinotify.Notifier(wm, handler)
wdd = wm.add_watch(FILE, pyinotify.IN_CLOSE_WRITE)
notifier.loop()
This is more efficient than polling. The kernel tells you when it does the operation, without you having to constantly ask.