Skip to content

Consolidate pathlib.PurePath.match() and full_match() #139282

Description

@barneygale

Whichever fool (me!) added pathlib.PurePath.full_match() should have given more consideration to adding an argument to match() instead of a new method. The behaviour isn't that different. The fact we have two very similar methods is a bit of a wart. It's hopefully not too late to rectify.

Linked PRs

Activity

  1. terryjreedy commented on Sep 24, 2025

    @terryjreedy
    Member

    match, the original.
    fullmatch, added in 3.13.
    Both have signature pattern, *, case_sensitive=None.
    Match had these restrictions and difference:

    empty patterns aren’t allowed (ValueError is raised), the recursive wildcard “**” isn’t supported (it acts like non-recursive “*”), and if a relative pattern is provided, then matching is done from the right:

    Since added recently, fullmatch might not have great usage yet. In 3.15, could add, for instance, 'full=False' to match and change doc to match. Deprecate 'fullmatch', with removal multiple versions away, such as 5 (no hurry).

  2. added a commit that references this issue on Sep 24, 2025
  3. barneygale commented on Sep 24, 2025

    @barneygale
    ContributorAuthor

    Thank you Terry for the helpful guidance :)

  4. added a commit that references this issue on Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-pathlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions