use it as an argument for the call to the glob.iglob, for every candidate in result, call the method os.path.basename with an argument candidate, is result is contained in targets,
if os . path . basename ( candidate ) in targets :