diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst index c24b2d539eb397..325a1cfe7caf74 100644 --- a/Doc/library/pathlib.rst +++ b/Doc/library/pathlib.rst @@ -600,10 +600,23 @@ Pure paths provide the following methods and properties: True >>> PurePath('a/b.py').full_match('*.py') False - >>> PurePath('/a/b/c.py').full_match('/a/**') - True >>> PurePath('/a/b/c.py').full_match('**/*.py') True + >>> PurePath('/a/b/c.py').full_match('/a/**') + True + + Patterns ending in "``/**``", as in the example above, may surprise when + passed to ``full_match``. Even though "``**``" can match 0 segments, + "``.../**``" requires a separator to match. Hence "``/a/**``" does not + match path "``/a``". Since :class:`PurePath` drops trailing slashes, this + pattern also does not match "``/a/``". + + :: + + >>> PurePath('/a').full_match('/a/**') + False + >>> PurePath('/a/').full_match('/a/**') + False .. seealso:: :ref:`pathlib-pattern-language` documentation. @@ -1814,6 +1827,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)