[Python-ideas] Allow iterable argument to os.walk()
Sven Marnach
sven at marnach.net
Sun Oct 30 19:31:36 CET 2011
Nick Coghlan schrieb am So, 30. Okt 2011, um 09:32:18 +1000:
> If people want to walk multiple directories, 3.3 will make that pretty easy:
>
> def walk_dirs(dirs):
> for dir in dirs:
> yield from os.walk(dir)
In earlier versions you can use
itertools.chain.from_iterable(map(os.walk, dirs))
to get an iterator that successively walks through the directory trees
rooted at the directories in "dirs".
-- Sven
More information about the Python-ideas
mailing list