Skip to content

Instantly share code, notes, and snippets.

@Horaddrim
Created March 26, 2018 11:44
Show Gist options
  • Save Horaddrim/c9b7e287d6c21a9b04933fd0f570014b to your computer and use it in GitHub Desktop.
Save Horaddrim/c9b7e287d6c21a9b04933fd0f570014b to your computer and use it in GitHub Desktop.
import os
import fnmatch
def gen_find(filepat,top):
for path, dirlist, filelist in os.walk(top):
for name in fnmatch.filter(filelist,filepat):
yield os.path.join(path,name)
# Example use
if __name__ == '__main__':
lognames = gen_find("access-log*","www")
for name in lognames:
print name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment