[Python-ideas] Adding '**' recursive search to glob.glob

Serhiy Storchaka storchaka at gmail.com
Mon Jan 14 17:14:55 CET 2013


On 14.01.13 15:22, Paul Moore wrote:
> This may be simple enough to just be a feature request on the tracker,
> but I thought I'd post it here first to see if people thought it was a
> good idea.

There were several issues on tracker for this feature. Issue 13968 has 
almost ready patch (I should only protect recursive glob from infinite 
symlink loops). Except symlink loops the patch looks working and you can 
try it and make a review. I'm going to finish the work this week.

> For people who don't know the syntax, "a/**/b" is equivalent to "a/*/b
> or a/*/*/b or a/*/*/*/b or ..." (for as many levels as needed).

Or a/b.

> One obvious downside is that if used carelessly, it can make globbing
> pretty slow. So I'd propose that it be added as an optional extension
> enabled using a flag argument (glob(pat, allow_recursive=True)) which
> is false by default. That would also mean that backward compatibility
> should not be an issue.

Indeed. That's why I added the "recursive" parameter and disable this by 
default.





More information about the Python-ideas mailing list