diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst index ab92c142c37a4f..e265f633c4f38a 100644 --- a/Doc/library/pathlib.rst +++ b/Doc/library/pathlib.rst @@ -575,6 +575,16 @@ Pure paths provide the following methods and properties: >>> PurePath('/a/b/c.py').full_match('**/*.py') True + A pattern ending in "``/**``" needs the separator before it to be present + in the path, even though "``**``" can match zero segments. For instance, + "``/a/**``" matches "``/a/b``" but not "``/a``", and since :class:`PurePath` + drops trailing slashes, it does not match "``/a/``" either:: + + >>> PurePath('/a/b').full_match('/a/**') + True + >>> PurePath('/a').full_match('/a/**') + False + .. seealso:: :ref:`pathlib-pattern-language` documentation. @@ -1796,6 +1806,8 @@ The following wildcards are supported in patterns for ``**`` (entire segment) Matches any number of file or directory segments, including zero. + Note that in :meth:`~PurePath.full_match`, "``a/**``" does not match + "``a``", whereas :meth:`~Path.glob` yields "``a``" for that pattern. ``*`` (entire segment) Matches one file or directory segment. ``*`` (part of a segment)