self.filename = '/path/to/file'

def ook(self):
    stamp = os.stat(self.filename).st_mtime
if stamp != self._cached_stamp:
    self._cached_stamp = stamp
How do I watch a file for changes using Python?