Skip to content

glob.glob() docs incorrectly describe include_hidden as only affecting ** pattern #148765

@EoinTrial

Description

@EoinTrial

Bug description

The documentation for glob.glob() and glob.iglob() describes the include_hidden parameter as:

If include_hidden is true, "**" pattern will match hidden directories.

This is inaccurate in two ways:

  1. The flag affects all wildcard patterns (*, ?, [...], **), not just **.
    For example, glob.glob('*',include_hidden=True) matches dotfiles in the current directory.
  2. "hidden directories" is misleading, since it refers to any path component whose name begins with a dot, not Windows FILE_ATTRIBUTE_HIDDEN.

This was raised on Python Discourse in September 2022 (https://discuss.python.org/t/new-glob-documentation-could-be-improved/19054) where @eryksun suggested the fix and @gvanrossum asked for an issue and PR.

The correct description (matching the wording already used in glob.translate() on line 164 of the same file) would be:

If include_hidden is true, patterns that do not begin with a dot may also match path components that begin with a dot.

CPython versions tested on:

3.11, 3.12, 3.13, 3.14

Operating systems tested on:

Any

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Status

    No status

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions