glob.glob() has a section like: if not has_magic(basename): result = [] for dirname in list: if basename or os.path.isdir(dirname): name = os.path.join(dirname, basename) if os.path.exists(name): result.append(name) else: For every iteration of the for loop, basename is tested, yet its value never changes. Am I missing something here or is this wasteful like i think it is?