Skip to content

Instantly share code, notes, and snippets.

@vadella
Created March 2, 2018 14:18
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 vadella/7ccd66ea12278acb398b7076b3462efa to your computer and use it in GitHub Desktop.
Save vadella/7ccd66ea12278acb398b7076b3462efa to your computer and use it in GitHub Desktop.
recursive or not via pathlib.Path
def files_under(directory, recursive=True):
root = Path(directory)
pattern = '**/*' if recursive else '*'
yield from root.glob(pattern)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment