Thanks to visit codestin.com
Credit goes to github.com

Skip to content

pathlib docs: Method Path.absolute is missing from docs <v3.11 (also distinction from Path.resolve and rel. topics) #121682

Closed as not planned
@e-d-n-a

Description

@e-d-n-a

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:

  1. Blame for Method Path.absolute()
  2. Commit including pathlib.py for v3.4
  3. Path.absolute() in Docs for v3.11
  4. Path.absolute and Path.resolve in code of v3.11.9 (docstring for Path.absolute is simplified here though!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions