<p>Ant has a nice way to select groups of files, most handily using ** to indicate a directory tree. E.g.</p>

<pre><code>**/CVS/*            # All files immediately under a CVS directory.
mydir/mysubdir/**   # All files recursively under mysubdir
</code></pre>

<p>More examples can be seen here:</p>

<p><a href="http://ant.apache.org/manual/dirtasks.html" rel="nofollow noreferrer">http://ant.apache.org/manual/dirtasks.html</a></p>

<p>How would you implement this in python, so that you could do something like:</p>

<pre><code>files = get_files("**/CVS/*")
for file in files:
    print file

=&gt;
CVS/Repository
mydir/mysubdir/CVS/Entries
mydir/mysubdir/foo/bar/CVS/Entries
</code></pre>

```
os.walk
```
is your friend. Look at the example in the Python manual 
(
https://docs.python.org/2/library/os.html#os.walk
) and try to build something from that.
To match "
```
**/CVS/*
```
" against a file name you get, you can do something like this:
```
```
def match(pattern, filename):
    if pattern.startswith("**"):
        return fnmatch.fnmatch(file, pattern[1:])
    else:
        return fnmatch.fnmatch(file, pattern)
```
```
In
```
fnmatch.fnmatch
```
, "*" matches anything (including slashes).