[issue26781] os.walk max_depth

Serhiy Storchaka report at bugs.python.org
Sat Apr 16 15:15:46 EDT 2016


Serhiy Storchaka added the comment:

os.walk() allows more flexible control.

    for root, dirs, files in os.walk(top):
        if is_too_deep(root):
            dirs.clear()
            continue
        ...

You can even walk up to different depth on different parts of the tree. You can limit walking not by the directory depth, but by the length of the path, or the number of links in the path, or what-you-need. Adding separate parameters for all this particular cases is not practical.

I think there is a little need in this feature.

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26781>
_______________________________________


More information about the Python-bugs-list mailing list