glob's new include_hidden parameter
Just spotted that 3.11 adds an include_hidden. At the moment a little confused because there's an apparent mismatch between docstring and docs. Lib/glob.py: If `include_hidden` is true, the patterns '*', '?', '**' will match hidden directories. Doc/library/glob.rst: If *include_hidden* is true, "``**``" pattern will match hidden directories. ,,, with no mention of the other patterns. Is that just an omission in the rst doc?
I think it's wrong in the docs. From looking at the code, that flag applies to all patterns, not just to `**`. (and "hidden" just means "begins with a dot") On Mon, Sep 12, 2022 at 9:04 AM Mats Wichmann <mats@wichmann.us> wrote:
Just spotted that 3.11 adds an include_hidden. At the moment a little confused because there's an apparent mismatch between docstring and docs.
Lib/glob.py:
If `include_hidden` is true, the patterns '*', '?', '**' will match hidden directories.
Doc/library/glob.rst:
If *include_hidden* is true, "``**``" pattern will match hidden directories.
,,, with no mention of the other patterns.
Is that just an omission in the rst doc?
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/QVZJAHFO... Code of Conduct: http://python.org/psf/codeofconduct/
-- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-c...>
On 9/12/22, Mats Wichmann <mats@wichmann.us> wrote:
If `include_hidden` is true, the patterns '*', '?', '**' will match hidden directories.
Shouldn't this explain what a "hidden directory" is? For example, a Windows user may think this means a directory with FILE_ATTRIBUTE_HIDDEN set, but that's not what's meant here. Also, I think it should note that enabling include_hidden negates the earlier claim that "files beginning with a dot (.) can only be matched by patterns that also start with a dot". For example, glob.glob('*', include_hidden=True) includes all of the conventionally hidden directories and hidden files in the current directory.
On 9/12/22 19:48, Eryk Sun wrote:
On 9/12/22, Mats Wichmann <mats@wichmann.us> wrote:
If `include_hidden` is true, the patterns '*', '?', '**' will match hidden directories.
Shouldn't this explain what a "hidden directory" is? For example, a Windows user may think this means a directory with FILE_ATTRIBUTE_HIDDEN set, but that's not what's meant here. Also, I think it should note that enabling include_hidden negates the earlier claim that "files beginning with a dot (.) can only be matched by patterns that also start with a dot". For example, glob.glob('*', include_hidden=True) includes all of the conventionally hidden directories and hidden files in the current directory.
sounds like a good point to me.
participants (3)
-
Eryk Sun
-
Guido van Rossum
-
Mats Wichmann