[Python-ideas] find-like functionality in pathlib

Sven R. Kunze srkunze at mail.de
Tue Jan 5 13:41:11 EST 2016


Don't get me wrong but either glob('**/*') and rglob('*') sounds quite 
cryptic. Furthermore, globbing always sounds slow to me.

Is it fast?
And is there some way to leave out the '*' (three special characters for 
plain ol'everything)?
And how can I walk directories only and files only?

On 05.01.2016 07:49, Guido van Rossum wrote:
> On Mon, Jan 4, 2016 at 9:25 PM, Guido van Rossum <guido at python.org 
> <mailto: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. :-)

Best,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160105/b8d72c1f/attachment.html>


More information about the Python-ideas mailing list