def is_dir(path):
return os.path.exists(path) and not os.path.isfile(path)
def dir_list(path):
dirs = []
for fname in os.listdir(path):
full_path = os.path.join(path, fname)
if is_dir(full_path):
dirs.append(full_path)
dirs += dir_list(full_path)
return dirs
for path, dirs, files in os.walk(path):
for f in dirs:
...