Skip to content

Commit 54f4826

Browse files
harjothkharaclaude
andcommitted
gh-139580: Clarify pathlib full_match recursive pattern docs
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent a700732 commit 54f4826

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Doc/library/pathlib.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,21 @@ Pure paths provide the following methods and properties:
575575
>>> PurePath('/a/b/c.py').full_match('**/*.py')
576576
True
577577

578+
A pattern ending with "``/**``" matches any path that begins with the
579+
pattern's prefix followed by a separator. For example "``/a/**``" matches
580+
"``/a/b``" and "``/a/b/c``", but not "``/a``", because "``/a``" does not
581+
begin with "``/a/``". The recursive wildcard "``**``" can match zero
582+
segments, but the separator before it must still be present in the path,
583+
and :class:`PurePath` objects do not preserve trailing slashes (so
584+
"``/a/``" is normalized to "``/a``")::
585+
586+
>>> PurePath('/a/b').full_match('/a/**')
587+
True
588+
>>> PurePath('/a').full_match('/a/**')
589+
False
590+
>>> PurePath('/a/').full_match('/a/**')
591+
False
592+
578593
.. seealso::
579594
:ref:`pathlib-pattern-language` documentation.
580595

0 commit comments

Comments
 (0)