Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions Doc/library/pathlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -586,10 +586,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.
Expand Down Expand Up @@ -1810,6 +1823,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)
Expand Down
Loading