Skip to content

Instantly share code, notes, and snippets.

@tallus
Last active December 24, 2015 19:09
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 tallus/6847975 to your computer and use it in GitHub Desktop.
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
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