Created
January 25, 2019 06:55
-
-
Save alxfv/95923acf8b0518e18085354dce47a8a8 to your computer and use it in GitHub Desktop.
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
def oswalk(dirname): | |
if not os.path.isdir(dirname): | |
return | |
names = os.listdir(dirname) | |
filenames = [] | |
dirnames = [] | |
dirpaths = [] | |
for name in names: | |
path = os.path.join(dirname, name) | |
if os.path.isdir(path): | |
dirnames.append(name) | |
dirpaths.append(path) | |
else: | |
filenames.append(name) | |
yield (dirname, dirnames, filenames) | |
for path in dirpaths: | |
yield from oswalk(path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment