GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `Path.rglob` -> documentation does not specify what `pattern` is · Issue #101112 · python/cpython

Path.rglob -> documentation does not specify what pattern is #101112

New issue
Copy link
New issue
Copy link
Closed
Closed
Path.rglob -> documentation does not specify what pattern is#101112
Copy link
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dirtopic-pathlib

Description

@jugmac00
jugmac00
opened on Jan 17, 2023
Issue body actions

Documentation

Today I came across Path.rglob in our codebase.

I went to https://docs.python.org/3/library/pathlib.html#pathlib.Path.rglob and tried to find out what pattern actually is. While the current documentation links to Path.glob(), I would like to add a note similar you can find at https://docs.python.org/3/library/pathlib.html#pathlib.Path.glob, ie

Patterns are the same as for fnmatch

Would a PR be welcome to add this kind of information?

Linked PRs

  • GH-101112: Specify type of pattern for Path.rglob #101132
  • GH-101112: Provide pattern overview for Path.glob #101223
  • GH-101112: Add "pattern language" section to pathlib docs #114030
Reacted by Barney Gale

Activity

  1. jugmac00
    added
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    on Jan 17, 2023
  2. AlexWaygood
    added
    topic-pathlib
    on Jan 17, 2023
  3. jugmac00
    added a commit that references this issue on Jan 18, 2023

    pythonGH-101112: Specify type of pattern for Path.rglob

    69aae06
  4. barneygale commented on Jan 18, 2023

    @barneygale
    barneygale
    on Jan 18, 2023
    Contributor
    More actions

    The documentation for glob() is wrong - the pattern is interpreted differently by fnmatch. In fnmatch(), the * wildcard can match directory separators, but in glob() it can't. The ** wildcard matches separators in glob(), but it can only appear in its own path segment.

    It should probably say "patterns are the same as for glob.glob()"

    Reacted by Jürgen Gmach and Alex Waygood
  5. jugmac00 commented on Jan 18, 2023

    @jugmac00
    jugmac00
    on Jan 18, 2023
    ContributorAuthor
    More actions

    Thanks!

    I will update my current PR, and I will also fix the documentation for Path.glob.

  6. jugmac00 commented on Jan 18, 2023

    @jugmac00
    jugmac00
    on Jan 18, 2023
    ContributorAuthor
    More actions

    On a second thought, and after reading the documentation for glob.glob(), I am not sure whether linking to it directly would be very helpful.

    • unlike the fnmatch documentation there is no syntax overview
    • unlike the fnmatch documentation there are no explanations (there are some above that paragraph)
    • glob.glob() has options to change its scope, ie include subdirectories and hidden directories; Path.glob does not have any options; just linking to glob.glob() would leave the reader in the dark whether Path.glob include these or not
    • the introductory paragraph mentions (emphasis on unlike)

    Note that files beginning with a dot (.) can only be matched by patterns that also start with a dot, unlike fnmatch.fnmatch() or pathlib.Path.glob()

    I think linking to glob.glob() would cause more confusion - at least as it is now.

    @barneygale What do you think of adding a pattern syntax table (similar to the one for fnmatch) to Path.glob and then link from Path.rglob to Path.glob? Or would that overstate the case? Or maybe I miss something.

    Reacted by Barney Gale
  7. barneygale commented on Jan 18, 2023

    @barneygale
    barneygale
    on Jan 18, 2023
    Contributor
    More actions

    @barneygale What do you think of adding a pattern syntax table (similar to the one for fnmatch) to Path.glob and then link from Path.rglob to Path.glob? Or would that overstate the case? Or maybe I miss something.

    I think that's an excellent idea. Perhaps something like:

    Pattern Meaning
    ** matches any number of nested directories
    * matches any part of a file or directory name
    ? matches any single character in a file or directory name
    [seq] matches any character in seq
    [!seq] matches any character not in seq
  8. barneygale commented on Jan 18, 2023

    @barneygale
    barneygale
    on Jan 18, 2023
    Contributor
    More actions

    The docs for PurePath.match() should also link to the table, but should note that ** is unsupported and works just like *.

  9. ambv
    added a commit that references this issue on Jan 20, 2023

    GH-101112: Specify type of pattern for Path.rglob (#101132)

    61f338a
  10. jugmac00
    added 5 commits that reference this issue on Jan 21, 2023

    pythonGH-101112: Provide pattern overview for Path.glob

    9365d78

    pythonGH-101112: Provide pattern overview for Path.glob

    8510576

    pythonGH-101112: Provide pattern overview for Path.glob

    23b12d4

    pythonGH-101112: Provide pattern overview for Path.glob

    ab1f568

    pythonGH-101112: Provide pattern overview for Path.glob

    6fc4c85
  11. barneygale
    added this to pathlib issueson Dec 2, 2023
  12. barneygale
    moved this to Todo in pathlib issueson Dec 4, 2023
  13. barneygale
    added a commit that references this issue on Jan 13, 2024

    pythonGH-101112: Add "pattern language" section to pathlib docs

    db927ea
  14. barneygale
    added 2 commits that reference this issue on Jan 26, 2024

    Merge branch 'main' into pythongh-101112

    3a0b6ce

    Merge branch 'main' into pythongh-101112

    d33037d
  15. barneygale
    added a commit that references this issue on Feb 26, 2024

    GH-101112: Add "pattern language" section to pathlib docs (#114030)

    e921f09
  16. barneygale commented on Feb 26, 2024

    @barneygale
    barneygale
    on Feb 26, 2024
    Contributor
    More actions

    Sorted in the 3.13 docs. Can backport if folks are interested, but it'll need to be a little different due to the introduction of full_match() in 3.13, and the fix for patterns ending **. Thanks for reporting @jugmac00.

    Reacted by Jürgen Gmach
  17. barneygale
    closed this as completedon Feb 26, 2024
  18. github-project-automation
    moved this from Todo to Done in pathlib issueson Feb 26, 2024
  19. woodruffw
    added a commit that references this issue on Mar 4, 2024

    pythonGH-101112: Add "pattern language" section to pathlib docs (pyth…

    c56c5fb
  20. adorilson
    added a commit that references this issue on Mar 25, 2024

    pythonGH-101112: Add "pattern language" section to pathlib docs (pyth…

    a33a073
  21. diegorusso
    added a commit that references this issue on Apr 17, 2024

    pythonGH-101112: Add "pattern language" section to pathlib docs (pyth…

    673a3f5
  22. LukasWoodtli
    added a commit that references this issue on Jan 22, 2025

    pythonGH-101112: Add "pattern language" section to pathlib docs (pyth…

    dee5761
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

    docsDocumentation in the Doc dirDocumentation in the Doc dirtopic-pathlib

    Projects

    • pathlib issues
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.