diff options
author | Jamiel Almeida <slashfoo@gmail.com> | 2017-06-02 18:36:02 (GMT) |
---|---|---|
committer | Brett Cannon <brettcannon@users.noreply.github.com> | 2017-06-02 18:36:02 (GMT) |
commit | ae8750bca8234a9af9382b9d7e457b57f810ad64 (patch) | |
tree | cc343ee843bce3f994a3eb4388201d8270a86577 /Doc/library/pathlib.rst | |
parent | 7a99625e0d95cd88ed8842d8677b5beea1fde5ae (diff) | |
download | cpython-ae8750bca8234a9af9382b9d7e457b57f810ad64.zip cpython-ae8750bca8234a9af9382b9d7e457b57f810ad64.tar.gz cpython-ae8750bca8234a9af9382b9d7e457b57f810ad64.tar.bz2 |
bpo-24899: Add comparison table for os.path -> pathlib (GH-1753)
Diffstat (limited to 'Doc/library/pathlib.rst')
-rw-r--r-- | Doc/library/pathlib.rst | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst index 1445226..0c9bd0d 100644 --- a/Doc/library/pathlib.rst +++ b/Doc/library/pathlib.rst @@ -1055,3 +1055,36 @@ call fails (for example because the path doesn't exist): 'Text file contents' .. versionadded:: 3.5 + +Correspondence to tools in the :mod:`os` module +----------------------------------------------- + +Below is a table mapping various :mod:`os` functions to their corresponding +:class:`PurePath`/:class:`Path` equivalent. + +.. note:: + + Although :func:`os.path.relpath` and :meth:`PurePath.relative_to` have some + overlapping use-cases, their semantics differ enough to warrant not + considering them equivalent. + +============================ ============================== +os and os.path pathlib +============================ ============================== +:func:`os.path.abspath` :meth:`Path.resolve` +:func:`os.getcwd` :func:`Path.cwd` +:func:`os.path.exists` :meth:`Path.exists` +:func:`os.path.expanduser` :meth:`Path.expanduser` and + :meth:`Path.home` +:func:`os.path.isdir` :meth:`Path.is_dir` +:func:`os.path.isfile` :meth:`Path.is_file` +:func:`os.path.islink` :meth:`Path.is_symlink` +:func:`os.stat` :meth:`Path.stat`, + :meth:`Path.owner`, + :meth:`Path.group` +:func:`os.path.isabs` :meth:`PurePath.is_absolute` +:func:`os.path.join` :func:`PurePath.joinpath` +:func:`os.path.basename` :data:`PurePath.name` +:func:`os.path.dirname` :data:`PurePath.parent` +:func:`os.path.splitext` :data:`PurePath.suffix` +============================ ============================== |