[Python-ideas] find-like functionality in pathlib
Guido van Rossum
guido at python.org
Tue Jan 5 01:49:18 EST 2016
On Mon, Jan 4, 2016 at 9:25 PM, Guido van Rossum <guido at python.org> wrote:
> Following up on this, in theory the right way to walk a tree using pathlib
> already exists, it's the rglob() method. E.g. all paths under /foo/bar
> should be found as follows:
>
> for path in pathlib.Path('/foo/bar').rglob('**/*'):
>
Whoops, I just realized that I combined two ways of doing a recursive glob
here. It should be either rglob('*') or plain glob('**/*'). What I wrote
produces identical results, but at the cost of a lot of caching. :-)
Note that the PEP doesn't mention rglob() -- why do we even have it? It
seems rglob(pat) is exactly the same as glob('**/' + path) (assuming os.sep
is '/'). No TOOWTDI here?
--
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160104/d8caf155/attachment-0001.html>
More information about the Python-ideas
mailing list