Last active
January 16, 2019 05:32
-
-
Save bombs-kim/67894a6831cc32bf86d54ec3617c184d to your computer and use it in GitHub Desktop.
paths_utils.py
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
import os | |
from os.path import abspath, exists, join, isdir, basename, dirname | |
def list_abs(root, files=True, dirs=False): | |
for path in os.listdir(root): | |
path = abspath(join(root, path)) | |
if isdir(path): | |
if dirs: yield path | |
yield from list_abs(path) | |
else: | |
if files: yield path |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment