Dictu
Dictu copied to clipboard
Add `Path.walk`
I'd be happy if it had the same semantics as Python's os.walk
This will have to be implemented using a class (e.g. Path.Walker
), since Dictu doesn't have stateful functions aka generators. The reason it needs to be stateful is because doing the entire tree traversal before returning limits the usefulness. For instance, if you wanted to search from the root directory and this feature returned a list of every path it would take ages to execute, and the results would use a large amount of memory. Instead we can create an instance of the class given the root of the filesystem tree to be traversed, and have a next
method (or some similar name) to get the next [path, dirnames, filenames]
triplet. When you call the next
method you can optionally provide an updated dirnames
list to prune the traversal.
Rationale makes perfect sense to me, I like it
446 implements the functionality required within Dictu, however, I'll keep this issue open as a reminder to add it to the stdlib once we work out a viable way of running Dictu code.