import os

def get_immediate_subdirectories(a_dir):
    return [name for name in os.listdir(a_dir) if os.path.isdir(os.path.
        join(a_dir, name))]
How to get all of the immediate subdirectories in Python