This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Path.relative_to() taking multiple arguments could be better documented
Type: Stage: patch review
Components: Documentation Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Antony.Lee, barneygale, docs@python, python-dev
Priority: normal Keywords: easy, patch

Created on 2018-08-28 08:42 by Antony.Lee, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 31368 open python-dev, 2022-02-16 08:01
Messages (1)
msg324224 - (view) Author: Antony Lee (Antony.Lee) * Date: 2018-08-28 08:42
Currently, the docs for Path.relative_to read

    PurePath.relative_to(*other)
    Compute a version of this path relative to the path represented by other. If it’s impossible, ValueError is raised: (examples follow)

It's a bit confusing why other is a star-args, especially as no example actually passes more than one argument to relative_to.

The docstring is a tiny bit clearer:

    Return the relative path to another path identified by the passed
    arguments.  If the operation is not possible (because this is not
    a subpath of the other path), raise ValueError.

Effectively, a Path is constructed from all *other args and used as base for the computation of the relative path.  It looks a bit like a misfeature to me, but at least it could be better documented (e.g. by adding `Path("/tmp/foo/bar").relative_to("/tmp", "foo") == Path("bar")` as example in the docs).
History
Date User Action Args
2022-04-11 14:59:05adminsetgithub: 78707
2022-02-16 08:01:06python-devsetkeywords: + patch
nosy: + python-dev

pull_requests: + pull_request29518
stage: patch review
2022-01-19 22:51:36barneygalesetnosy: + barneygale
2022-01-19 00:08:14iritkatrielsetkeywords: + easy
versions: + Python 3.9, Python 3.10, Python 3.11, - Python 3.7
2018-08-28 08:42:29Antony.Leecreate