
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@python.org <mailto:guido@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