class GetPic(pyinotify.ProcessEvent): def process_IN_CREATE(self, event): outFile = open('lastPic.txt', 'w') outFile.write(event.pathname) class MainClass(): .... some code here (not important for this problem)... def runOCR(self): wm = pyinotify.WatchManager() notifier = pyinotify.Notifier(wm, GetPic()) wm.add_watch('/home/user/MyDocs/DCIM', pyinotify.IN_CREATE) os.system('dbus-send --session --print-reply --dest=com.nokia.cameraui /com/nokia/cameraui com.nokia.cameraui.top_application') notifier.loop(callback=OnSave) notifier.stop() def OnSave(notifier): inFile = open('lastPic.txt','r') lastFile = inFile.read() return True