Suppose I have a subdirectory of symlinks that looks like the following:
subdir/
folder/
readme.txt
symlink/ => ../hidden/
hidden/
readme.txt
If I run the following code:
>>> from pathlib import Path
>>> list(Path('./subdir/').glob('**/readme.txt'))
I would expect the outcome to be:
subdir/folder/readme.txt
subdir/symlink/readme.txt
But the actual result is:
subdir/folder/readme.txt
I found out that this is because (for some undocumented reason) the ** operator doesn't follow symlinks.
Is there a way to change this configuration pragmatically?
glob
to optionally not follow symlinks. – Interject_iterate_directories()
in class_RecursiveWildcardSelector
of pathlib.py explicitly ignores symlinks. – Aldosterone