Description
Documentation
Method Path.absolute
is missing from docs <v3.11 (I checked all of them: 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10).
It only appears in docs for v3.11+[3], although it is part of the class Path since pathlib
was added in v3.4[1,2].
It would be useful to have, as one needs to see the distinction between Path.absolute
and Path.resolve
(which is included in the docs since v3.4) in regards to normalization or resolving symlinks for example (see docstrings or docs for v3.11[3]).
Docstrings taken from pathlib.py
of v3.9.17:
(I appreciate the explicit mentioning of the treatment of '.' and '..' with Path.absolute in this version!)
def absolute(self):
"""Return an absolute version of this path. This function works
even if the path doesn't point to anything.
No normalization is done, i.e. all '.' and '..' will be kept along.
Use resolve() to get the canonical path to a file.
"""
def resolve(self, strict=False):
"""
Make the path absolute, resolving all symlinks on the way and also
normalizing it (for example turning slashes into backslashes under
Windows).
"""
(these functions also appear next to each other in the code[4])
It would be nice, if the topics of "path normalization" and "symlink resolving" would be described more clearly in the context of those functions. The handling of '..' is mentioned in the context of Path.resolve
and also PurePaths
(in constructor and PurePath.parent
).
Yet, the trap with Path.absolute
is only mentioned by the documenation for Path.resolve
stating:
“..” components are also eliminated (this is the only method to do so):
Refs:
- Blame for Method Path.absolute()
- Commit including pathlib.py for v3.4
- Path.absolute() in Docs for v3.11
- Path.absolute and Path.resolve in code of v3.11.9 (docstring for Path.absolute is simplified here though!)