Skip to content

Instantly share code, notes, and snippets.

@dmwyatt
Last active December 6, 2019 18:39
Show Gist options
  • Save dmwyatt/54b92611d6d11711a0aa to your computer and use it in GitHub Desktop.
Save dmwyatt/54b92611d6d11711a0aa to your computer and use it in GitHub Desktop.
[Recursive glob.] Demo of `fnmatch`. Matches filenames, recursively. From http://stackoverflow.com/questions/2186525/use-a-glob-to-find-files-recursively-in-python
import fnmatch
import os
matches = []
for root, dirnames, filenames in os.walk("src"):
for filename in fnmatch.filter(filenames, "*.c"):
matches.append(os.path.join(root, filename))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment