Last active
December 24, 2015 19:09
-
-
Save tallus/6847975 to your computer and use it in GitHub Desktop.
Python functions that returns a list of directories in a directory, with fully qualified paths, using ridiculous list constructor that I'm quite proud of
This file contains 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 get_directory_list(dpath): | |
'''returns a list of directories in a directory, | |
with fully qualified paths''' | |
if not os.path.isdir(dpath): | |
raise MyError('oops %s is not a directory'% dpath) | |
dirs = [os.path.join(dpath, filename) for filename in os.listdir(dpath) if (os.path.isdir(os.path.join(dpath, filename)))] | |
return dirs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment