There is no builtin way to do this, and glob
definitely in not suitable for it. You can build it on top of os.walk
I guess: filter the files
array at each step, as well as modify dirs
in-place to avoid recursing into hidden directories.
Do note that the Unix conception of hidden files (the dotfile hack) isn't necessarily sufficient (or compatible, kind-of) for other OS e.g. macOS does use dotfiles but also has a stat flag (UF_HIDDEN
), and Windows should only use the relevant stat flag (FILE_ATTRIBUTE_HIDDEN
) though ignoring dotfiles probably doesn't help.
Ideally there'd be a filewalker which would do that automatically, including support for ignorefiles (similar to Rust's ignore library), but pypi doesn't really surface anything, half the packages are about creating ignorefiles, and the rest is either incomplete or abandoned.