result_found = any(['foo' in x for x in os.listdir('something') if os.path.isfile(x)]) # The above is the same as what is below results = [] for entry in os.listdir('something'): if os.path.isfile(entry): if 'foo' in entry: results.append(True) else: results.append(False)