@@ -1765,39 +1765,54 @@ Corresponding tools
17651765Below is a table mapping various :mod: `os ` functions to their corresponding
17661766:class: `PurePath `/:class: `Path ` equivalent.
17671767
1768- ==================================== ==============================
1769- :mod: `os ` and :mod: `os.path ` :mod: `pathlib `
1770- ==================================== ==============================
1771- :func: `os.path.abspath ` :meth: `Path.absolute `
1772- :func: `os.path.realpath ` :meth: `Path.resolve `
1773- :func: `os.chmod ` :meth: `Path.chmod `
1774- :func: `os.mkdir ` :meth: `Path.mkdir `
1775- :func: `os.makedirs ` :meth: `Path.mkdir `
1776- :func: `os.rename ` :meth: `Path.rename `
1777- :func: `os.replace ` :meth: `Path.replace `
1778- :func: `os.rmdir ` :meth: `Path.rmdir `
1779- :func: `os.remove `, :func: `os.unlink ` :meth: `Path.unlink `
1780- :func: `os.getcwd ` :func: `Path.cwd `
1781- :func: `os.path.exists ` :meth: `Path.exists `
1782- :func: `os.path.expanduser ` :meth: `Path.expanduser ` and
1783- :meth: `Path.home `
1784- :func: `os.listdir ` :meth: `Path.iterdir `
1785- :func: `os.walk ` :meth: `Path.walk `
1786- :func: `os.path.isdir ` :meth: `Path.is_dir `
1787- :func: `os.path.isfile ` :meth: `Path.is_file `
1788- :func: `os.path.islink ` :meth: `Path.is_symlink `
1789- :func: `os.link ` :meth: `Path.hardlink_to `
1790- :func: `os.symlink ` :meth: `Path.symlink_to `
1791- :func: `os.readlink ` :meth: `Path.readlink `
1792- :func: `os.path.relpath ` :meth: `PurePath.relative_to `
1793- :func: `os.stat ` :meth: `Path.stat `,
1794- :meth: `Path.owner `,
1795- :meth: `Path.group `
1796- :func: `os.path.isabs ` :meth: `PurePath.is_absolute `
1797- :func: `os.path.join ` :func: `PurePath.joinpath `
1798- :func: `os.path.basename ` :attr: `PurePath.name `
1799- :func: `os.path.dirname ` :attr: `PurePath.parent `
1800- :func: `os.path.samefile ` :meth: `Path.samefile `
1801- :func: `os.path.splitext ` :attr: `PurePath.stem ` and
1802- :attr: `PurePath.suffix `
1803- ==================================== ==============================
1768+ ===================================== ==============================================
1769+ :mod: `os ` and :mod: `os.path ` :mod: `pathlib `
1770+ ===================================== ==============================================
1771+ :func: `os.path.dirname ` :attr: `PurePath.parent `
1772+ :func: `os.path.basename ` :attr: `PurePath.name `
1773+ :func: `os.path.splitext ` :attr: `PurePath.stem `, :attr: `PurePath.suffix `
1774+ :func: `os.path.join ` :meth: `PurePath.joinpath `
1775+ :func: `os.path.isabs ` :meth: `PurePath.is_absolute `
1776+ :func: `os.path.relpath ` :meth: `PurePath.relative_to ` [1 ]_
1777+ :func: `os.path.expanduser ` :meth: `Path.expanduser ` [2 ]_
1778+ :func: `os.path.realpath ` :meth: `Path.resolve `
1779+ :func: `os.path.abspath ` :meth: `Path.absolute ` [3 ]_
1780+ :func: `os.path.exists ` :meth: `Path.exists `
1781+ :func: `os.path.isfile ` :meth: `Path.is_file `
1782+ :func: `os.path.isdir ` :meth: `Path.is_dir `
1783+ :func: `os.path.islink ` :meth: `Path.is_symlink `
1784+ :func: `os.path.isjunction ` :meth: `Path.is_junction `
1785+ :func: `os.path.ismount ` :meth: `Path.is_mount `
1786+ :func: `os.path.samefile ` :meth: `Path.samefile `
1787+ :func: `os.getcwd ` :meth: `Path.cwd `
1788+ :func: `os.stat ` :meth: `Path.stat `
1789+ :func: `os.lstat ` :meth: `Path.lstat `
1790+ :func: `os.listdir ` :meth: `Path.iterdir `
1791+ :func: `os.walk ` :meth: `Path.walk ` [4 ]_
1792+ :func: `os.mkdir `, :func: `os.makedirs ` :meth: `Path.mkdir `
1793+ :func: `os.link ` :meth: `Path.hardlink_to `
1794+ :func: `os.symlink ` :meth: `Path.symlink_to `
1795+ :func: `os.readlink ` :meth: `Path.readlink `
1796+ :func: `os.rename ` :meth: `Path.rename `
1797+ :func: `os.replace ` :meth: `Path.replace `
1798+ :func: `os.remove `, :func: `os.unlink ` :meth: `Path.unlink `
1799+ :func: `os.rmdir ` :meth: `Path.rmdir `
1800+ :func: `os.chmod ` :meth: `Path.chmod `
1801+ :func: `os.lchmod ` :meth: `Path.lchmod `
1802+ ===================================== ==============================================
1803+
1804+ .. rubric :: Footnotes
1805+
1806+ .. [1 ] :func: `os.path.relpath ` calls :func: `~os.path.abspath ` to make paths
1807+ absolute and remove "``.. ``" parts, whereas :meth: `PurePath.relative_to `
1808+ is a lexical operation that raises :exc: `ValueError ` when its inputs'
1809+ anchors differ (e.g. if one path is absolute and the other relative.)
1810+ .. [2 ] :func: `os.path.expanduser ` returns the path unchanged if the home
1811+ directory can't be resolved, whereas :meth: `Path.expanduser ` raises
1812+ :exc: `RuntimeError `.
1813+ .. [3 ] :func: `os.path.abspath ` removes "``.. ``" components without resolving
1814+ symlinks, which may change the meaning of the path, whereas
1815+ :meth: `Path.absolute ` leaves any "``.. ``" components in the path.
1816+ .. [4 ] :func: `os.walk ` always follows symlinks when categorizing paths into
1817+ *dirnames * and *filenames *, whereas :meth: `Path.walk ` categorizes all
1818+ symlinks into *filenames * when *follow_symlinks * is false (the default.)
0 commit comments