Skip to content

Commit 1459fed

Browse files
authored
Doc: os.path.abspath and Path.resolve are also different (GH-23276)
1 parent 3554fa4 commit 1459fed

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Doc/library/pathlib.rst

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,14 +1195,15 @@ Below is a table mapping various :mod:`os` functions to their corresponding
11951195

11961196
.. note::
11971197

1198-
Although :func:`os.path.relpath` and :meth:`PurePath.relative_to` have some
1199-
overlapping use-cases, their semantics differ enough to warrant not
1200-
considering them equivalent.
1198+
Not all pairs of functions/methods below are equivalent. Some of them,
1199+
despite having some overlapping use-cases, have different semantics. They
1200+
include :func:`os.path.abspath` and :meth:`Path.resolve`,
1201+
:func:`os.path.relpath` and :meth:`PurePath.relative_to`.
12011202

12021203
==================================== ==============================
1203-
os and os.path pathlib
1204+
:mod:`os` and :mod:`os.path` :mod:`pathlib`
12041205
==================================== ==============================
1205-
:func:`os.path.abspath` :meth:`Path.resolve`
1206+
:func:`os.path.abspath` :meth:`Path.resolve` [#]_
12061207
:func:`os.chmod` :meth:`Path.chmod`
12071208
:func:`os.mkdir` :meth:`Path.mkdir`
12081209
:func:`os.makedirs` :meth:`Path.mkdir`
@@ -1221,6 +1222,7 @@ os and os.path pathlib
12211222
:func:`os.link` :meth:`Path.link_to`
12221223
:func:`os.symlink` :meth:`Path.symlink_to`
12231224
:func:`os.readlink` :meth:`Path.readlink`
1225+
:func:`os.path.relpath` :meth:`Path.relative_to` [#]_
12241226
:func:`os.stat` :meth:`Path.stat`,
12251227
:meth:`Path.owner`,
12261228
:meth:`Path.group`
@@ -1231,3 +1233,8 @@ os and os.path pathlib
12311233
:func:`os.path.samefile` :meth:`Path.samefile`
12321234
:func:`os.path.splitext` :data:`PurePath.suffix`
12331235
==================================== ==============================
1236+
1237+
.. rubric:: Footnotes
1238+
1239+
.. [#] :func:`os.path.abspath` does not resolve symbolic links while :meth:`Path.resolve` does.
1240+
.. [#] :meth:`Path.relative_to` requires ``self`` to be the subpath of the argument, but :func:`os.path.relpath` does not.

0 commit comments

Comments
 (0)