From: Guido van Rossum Date: Wed, 6 Jan 2016 19:36:03 +0000 (-0800) Subject: Cross-reference os.DirEntry and pathlib.Path for issue #22570. X-Git-Tag: v3.6.0a1~819^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1469d744bccbf7c6357bd23f06851d70f538f7e6;p=python Cross-reference os.DirEntry and pathlib.Path for issue #22570. --- diff --git a/Doc/library/os.rst b/Doc/library/os.rst index 144d9b24c8..dcdc4ec0ea 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -2035,6 +2035,12 @@ features: The result is cached on the ``DirEntry`` object. Call :func:`os.stat` to fetch up-to-date information. + Note that there is a nice correspondence between several attributes + and methods of ``DirEntry`` and of :class:`pathlib.Path`. In + particular, the ``name`` and ``path`` attributes have the same + meaning, as do the ``is_dir()``, ``is_file()``, ``is_symlink()`` + and ``stat()`` methods. + .. versionadded:: 3.5 diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst index 9c8ca58b33..a7ce18df33 100644 --- a/Doc/library/pathlib.rst +++ b/Doc/library/pathlib.rst @@ -381,7 +381,11 @@ Pure paths provide the following methods and properties: ``arg = str(arg)``, this will still raise an exception if an object of some other type is given by accident. + A nice advantage is that this protocol is also supported by + :class:`os.DirEntry` objects returned by :func:`os.scandir`. + .. versionadded:: 3.4.5 + .. versionadded:: 3.5.2 .. data:: PurePath.suffix