def list_dir(root, prefix=False):
root = os.path.expanduser(root)<EOL>directories = list(<EOL>filter(<EOL>lambda p: os.path.isdir(os.path.join(root, p)),<EOL>os.listdir(root)<EOL>)<EOL>)<EOL>if prefix is True:<EOL><INDENT>directories = [os.path.join(root, d) for d in directories]<EOL><DEDENT>return directories<EOL>
List all directories at a given root

    Args:
        root (str): Path to directory whose folders need to be listed
        prefix (bool, optional): If true, prepends the path to each result, otherwise
            only returns the name of the directories found