Consider this folder containing two files:
test/
foo
.bar
Calling glob.glob('*')
on this folder won't list the hidden .bar
file:
>>> glob.glob('test/*')
['test/foo']
But pathlib.Path.glob('*')
will:
>>> list(Path('test').glob('*'))
[PosixPath('test/.bar'), PosixPath('test/foo')]
I'd like to know if this is intended or possibly a bug/oversight.
The glob
module documentation states that files starting with a dot are special cased:
glob treats filenames beginning with a dot (.) as special cases
Meaning that the result given by glob.glob('*')
is intended. But what about pathlib's glob
? I couldn't find any relevant information in the docs. Is this the intended behavior? Shouldn't both functions produce the same results?
As per issue #26096 on the official bug tracker, this difference has been deemed not a bug
and is therefore completely intended.
Credits to @vaultah for the find.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With