Created
July 31, 2013 23:07
-
-
Save jayzeng/6127034 to your computer and use it in GitHub Desktop.
find files per pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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