Skip to content

Instantly share code, notes, and snippets.

@jayzeng
Created July 31, 2013 23:07
Show Gist options
  • Save jayzeng/6127034 to your computer and use it in GitHub Desktop.
Save jayzeng/6127034 to your computer and use it in GitHub Desktop.
find files per pattern
import os
import fnmatch
def gen_find(filepath, loc):
for path, diralist, filelist in os.walk(loc):
for name in fnmatch.filter(filelist, filepath):
yield os.path.join(path, name)
pyfiles = gen_find('*.py', '.')
for file in pyfiles:
print file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment