I want to glob with absolute path similar to the posed problem/solution in https://stackoverflow.com/questions/56311703/globbing-absolute-paths-with-pathlib.
The only difference is that the provided absolute path may have a different anchor than "/"
.
Using glob works fine and is concise
import glob
pathname = "\\\\www.abc.def\\fs\\foo\\bar/*"
glob.glob(pathname)
However, trying to achieve this using pathlib
is not really concise anymore.
My solution so far reads
Path(Path(pathname).anchor).glob(Path(pathname).relative_to(Path(pathname).anchor).as_posix())
The approach here is to extract the anchor and glob relative to this anchor with the rest of the string.
Is there a better solution using pathlib
?