Have a `.realpath` classmethod in pathlib.Path

But this is not public/documented. Are you suggesting that we change that?

+1 on this, although in practice I suspect it would mostly be a convenience for people who already use ctypes to get that data. Casual users are going to look at the list of known folders and get scared off (that’s a Windows issue that Python can’t really do much about).

1 Like

Just noting that I’ve put in a pull request to add documentation and tests for Path.absolute().

Overall I concur with Eryk Sun’s analysis.

It doesn’t make sense to normalize a path without resolving symlinks, as doing so can change the meaning of the path (consider somesymlink/..)

Nor does it make sense to resolve symlinks in a path without normalizing as you go, as symlink targets may themselves be relative paths like ../blah.

That leaves two remaining reasonable options:

  • Resolve symlinks and normalize, which is what Path.resolve() does.
  • Neither resolve symlinks nor normalize, which is what Path.absolute() does.

I believe that the Windows implementation, while nuanced, is still consistent with these facts.

Such a classmethod would be really helpful, I find myself using .expanduser().resolve() enough that I would love to replace them with this.