[issue13375] Provide a namedtuple style interface for os.walk values

Nick Coghlan report at bugs.python.org
Thu Nov 10 03:45:44 CET 2011


Nick Coghlan <ncoghlan at gmail.com> added the comment:

Why provide any namedtuple interface in any context? After all, you can just unpack them to individual variables.

The point is that the values produced by os.walk() *aren't* just an arbitrary 3-tuple - they have a definite API for describing a directory: the base path, then lists of relative names for any subdirectories and the relative names for any files. Why not make that explicit in the objects produced instead of leaving it as merely implied?

This idea actually came out of the proposal for providing an itertools-inspired toolset for manipulating the output of os.walk() style iteration (#13229 and https://bitbucket.org/ncoghlan/walkdir/overview).

I'll be adding this feature to walkdir regardless, but it seems to make more sense to offer it as standard behaviour.

----------

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


More information about the Python-bugs-list mailing list