Check whether two paths point to the same thing using Pathlib, even when target doesn't exist

Viewed 417

How do I check whether to pathlib.Path's point at the same file system location?

I hoped I could use .samefile, but that doesn't work when the files/directories don't exist yet.

Simple == also doesn't seem to work: Path("test/../file")!=Path("file")

EDIT: Even Path("test/../file").resolve().absolute()!=Path("file").resolve().absolute() in general (for example, when I run this on a network drive, the former resolves to //networkaddress/file and the latter to Z:/file

0 Answers
Related