def find_file(pattern, path):
    """
    A bit like grep. Finds a pattern, looking in path. Returns the filename.
    """
    for fname in glob.iglob(path):
        with open(fname) as f:
            if re.search(pattern, f.read()):
                return fname
    return
def find_file ( pattern , path ) : for fname in glob . iglob ( path ) : with open ( fname ) as f : if re . search ( pattern , f . read ( ) ) : return fname return
A bit like grep. Finds a pattern, looking in path. Returns the filename.