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

Paul Moore p.f.moore at gmail.com
Mon Jan 14 17:25:59 CET 2013


On 14 January 2013 16:14, Serhiy Storchaka <storchaka at gmail.com> wrote:
>
>> 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.

Hmm, from my experiments, bash doesn't show a/b as matching the
pattern 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.

Although I can see Vinay's point, that ** is not useful syntax
currently, so there's no compatibility problem. Careless use resulting
in long glob times is more of a user issue.

Having said that, this debate is *precisely* why I suggested making it
a parameter in the first place, so people can choose for themselves.
So I guess I agree with your decision :-)

Paul.



More information about the Python-ideas mailing list