История изменений
Исправление vvn_black, (текущая версия) :
$ tree
.
├── test
├── test1
├── test2
├── test3
└── walk.py
import os
path = '.'
exclude_dir = './test'
excluded = [*filter(lambda x: exclude_dir == x,
map(lambda x: x[0], os.walk(path))), ]
print(excluded)
without_excluded = [*filter(lambda x: exclude_dir != x,
map(lambda x: x[0], os.walk(path))), ]
print(without_excluded)
['./test']
['.', './test2', './test1', './test3']
Исходная версия vvn_black, :
$ tree
.
├── test
├── test1
├── test2
├── test3
└── walk.py
import os
path = '.'
exclude_dir = './test'
excluded = [*filter(lambda x: exclude_dir == x,
map(lambda x: x[0], os.walk(path))), ]
print(excluded)
without_excluded = [*filter(lambda x: exclude_dir != x,
map(lambda x: x[0], os.walk(path))), ('./test', [], [])
('.', ['test2', 'test1', 'test3', 'test'], ['walk.py']) ('./test2', [], []) ('./test1', [], []) ('./test3', [], [])
]
print(without_excluded)
['./test']
['.', './test2', './test1', './test3']