Skip to content

Instantly share code, notes, and snippets.

@Lyokolux
Last active January 13, 2019 12:47
Show Gist options
  • Save Lyokolux/ae58af62858b59e38a52494ccd105c00 to your computer and use it in GitHub Desktop.
Save Lyokolux/ae58af62858b59e38a52494ccd105c00 to your computer and use it in GitHub Desktop.
import os
import pathlib
# Usage :
# for filename in walker(ROOT_PATH):
# code...
def walker(path):
for (_, dirs, files) in os.walk(path):
for name in files:
yield pathlib.PurePath(path).joinpath(name)
for name in dirs:
walker(pathlib.PurePath(path).joinpath(name))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment