Skip to content

Instantly share code, notes, and snippets.

@aliang
Created December 21, 2011 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aliang/1507475 to your computer and use it in GitHub Desktop.
Save aliang/1507475 to your computer and use it in GitHub Desktop.
recursive globbing
def find_files(directory, pattern):
for root, dirs, files in os.walk(directory):
for basename in files:
if fnmatch.fnmatch(basename, pattern):
filename = os.path.join(root, basename)
yield filename
for f in find_files(".", "*.txt"):
print f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment