import gio

def directory_changed(monitor, file1, file2, evt_type):
    if evt_type in (gio.FILE_MONITOR_EVENT_CREATED, gio.
        FILE_MONITOR_EVENT_DELETED):
        print('Changed:', file1, file2, evt_type)
gfile = gio.File('.')
monitor = gfile.monitor_directory(gio.FILE_MONITOR_NONE, None)
monitor.connect('changed', directory_changed)
detect new or modified files with python