Skip to content

Commit ae8750b

Browse files
slashfoobrettcannon
authored andcommitted
bpo-24899: Add comparison table for os.path -> pathlib (pythonGH-1753)
1 parent 7a99625 commit ae8750b

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

Doc/library/pathlib.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,3 +1055,36 @@ call fails (for example because the path doesn't exist):
10551055
'Text file contents'
10561056

10571057
.. versionadded:: 3.5
1058+
1059+
Correspondence to tools in the :mod:`os` module
1060+
-----------------------------------------------
1061+
1062+
Below is a table mapping various :mod:`os` functions to their corresponding
1063+
:class:`PurePath`/:class:`Path` equivalent.
1064+
1065+
.. note::
1066+
1067+
Although :func:`os.path.relpath` and :meth:`PurePath.relative_to` have some
1068+
overlapping use-cases, their semantics differ enough to warrant not
1069+
considering them equivalent.
1070+
1071+
============================ ==============================
1072+
os and os.path pathlib
1073+
============================ ==============================
1074+
:func:`os.path.abspath` :meth:`Path.resolve`
1075+
:func:`os.getcwd` :func:`Path.cwd`
1076+
:func:`os.path.exists` :meth:`Path.exists`
1077+
:func:`os.path.expanduser` :meth:`Path.expanduser` and
1078+
:meth:`Path.home`
1079+
:func:`os.path.isdir` :meth:`Path.is_dir`
1080+
:func:`os.path.isfile` :meth:`Path.is_file`
1081+
:func:`os.path.islink` :meth:`Path.is_symlink`
1082+
:func:`os.stat` :meth:`Path.stat`,
1083+
:meth:`Path.owner`,
1084+
:meth:`Path.group`
1085+
:func:`os.path.isabs` :meth:`PurePath.is_absolute`
1086+
:func:`os.path.join` :func:`PurePath.joinpath`
1087+
:func:`os.path.basename` :data:`PurePath.name`
1088+
:func:`os.path.dirname` :data:`PurePath.parent`
1089+
:func:`os.path.splitext` :data:`PurePath.suffix`
1090+
============================ ==============================

Misc/ACKS

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Fred Allen
3333
Jeff Allen
3434
Ray Allen
3535
Billy G. Allie
36+
Jamiel Almeida
3637
Kevin Altis
3738
Skyler Leigh Amador
3839
Joe Amenta
@@ -436,6 +437,7 @@ Tim Everett
436437
Paul Everitt
437438
David Everly
438439
Daniel Evers
440+
evilzero
439441
Winston Ewert
440442
Greg Ewing
441443
Martijn Faassen
@@ -523,6 +525,7 @@ Elazar (אלעזר) Gershuni
523525
Ben Gertzfield
524526
Nadim Ghaznavi
525527
Dinu Gherman
528+
Subhendu Ghosh
526529
Jonathan Giddy
527530
Johannes Gijsbers
528531
Michael Gilfix
@@ -1242,6 +1245,7 @@ Jérôme Radix
12421245
Burton Radons
12431246
Abhilash Raj
12441247
Shorya Raj
1248+
Dhushyanth Ramasamy
12451249
Jeff Ramnani
12461250
Bayard Randel
12471251
Varpu Rantala
@@ -1505,6 +1509,7 @@ Nathan Sullivan
15051509
Mark Summerfield
15061510
Reuben Sumner
15071511
Eryk Sun
1512+
Sanjay Sundaresan
15081513
Marek Šuppa
15091514
Hisao Suzuki
15101515
Kalle Svensson
@@ -1747,7 +1752,3 @@ Jelle Zijlstra
17471752
Gennadiy Zlobin
17481753
Doug Zongker
17491754
Peter Åstrand
1750-
evilzero
1751-
Dhushyanth Ramasamy
1752-
Subhendu Ghosh
1753-
Sanjay Sundaresan

0 commit comments

Comments
 (0)