well you don't need to add check, just instead of returning False as default value, return an empty string ''. This way os.path.join won't crash and glob.glob will return an empty list, which is what you want.