def One(): duble = [] for l in open("log.log"): duble.append(l) for i in set(duble): f = Two(i.rstrip()) def Two(*args): for fname in glob.glob('test*.txt'): for line in open(fname): if args[0]==line: retrun line 

The question is how in the Two () function to read all files once and find what you need in the read, and such an algorithm works, for each line it reads all files every time.

    1 answer 1

     def log_read() with open('log.log') as fp: return frozenset([l.rstrip() for l in fp]) def log_search(logs): for file in glob.glob('test*.txt'): with open(file) as fp: for line in fp: if line in logs: return line