code: def finddirs(pattern, path='.', exclude=None, recursive=True):
      
      import fnmatch
      import os
      if recursive:
          for root, dirnames, filenames in os.walk(path):
              for pat in _to_list(pattern):
                  for dirname in fnmatch.filter(dirnames, pat):
                      dirpath = join(abspath(root), dirname)
                      for excl in _to_list(exclude):
                          if excl and fnmatch.fnmatch(dirpath, excl):
                              break
                      else:
                          yield dirpath
      else:
          for pat in _to_list(pattern):
              for dirname in fnmatch.filter(listdirs(path), pat):
                  dirpath = join(abspath(path), dirname)
                  for excl in _to_list(exclude):
                      if excl and fnmatch.fnmatch(dirpath, excl):
                          break
                  else:
                      yield dirpath
docs: Find directories that match *pattern* in *path*