New submission from Jacek Pliszka <jacek.plis...@gmail.com>: I suggest a small change in os.walk module.
Instead of: def walk(top, topdown=True, onerror=None, followlinks=False): I would like to have: def walk(top, topdown=True, onerror=None, skipnames=lambda x : False, skipdirs=islink): Implementation might be as follows: < if isdir(join(top, name)): --- > fullname=join(top, name) > if skipnames(fullname): > continue > if isdir(fullname): and: < if followlinks or not islink(new_path): < for x in walk(new_path, topdown, onerror, followlinks): --- > if not skipdirs(new_path): > for x in walk(new_path, topdown, onerror, skipnames, skipdirs): This is a small change, breaks a bit 'followlinks' option but gives much more flexibility as skipnames and skidirs can be any functions (including ones using regexp and similar). ---------- components: Library (Lib) files: os.diff keywords: patch messages: 142523 nosy: Jacek.Pliszka priority: normal severity: normal status: open title: allow filters in os.walk type: feature request versions: Python 3.2 Added file: http://bugs.python.org/file22960/os.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue12793> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com