Not sure how useful this is, but I ended up writing my own "pythonic find" module: https://github.com/moloney/pathmap/blob/master/pathmap.py
I was mostly worried about minimizing stat calls, so I used scandir rather than Pathlib.
The only documentation is the doc strings, but the basic idea is you can have one "matching" rule and any number of ignore/prune rules. The rules can be callables or strings that are treated as regular expressions (I suppose it might be better if the default was to treat strings as glob expressions instead...).
So for the original use case that spawned this thread, you would do something like:
pm = PathMap(prune_rules=['/.git$']) for match in pm.matches(['path/to/some/dir']): if not match.dir_entry.is_dir(): print(match.path)
Or if you wanted to do something similar but only print names of python modules it would be something like:
pm = PathMap('.+/(.+).py$', prune_rules=['/.git$']) for match in pm.matches(['path/to/some/dir']): if not match.dir_entry.is_dir(): print(match.match_info)