-
-
Notifications
You must be signed in to change notification settings - Fork 31k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent behaviour between pathlib.PurePath.match
and glob.glob
#118701
Comments
Follow-up: May be connected with #106747 |
cc @barneygale |
Could you try using >>> import pathlib
>>> path = pathlib.PurePath("a/b/c/d/e")
>>> path.full_match("**/b/c/**")
True
>>> path.full_match("**/c/d/**")
True |
Oh, I see. So, this is intended. Thank you for quick reply! Is it possible then to add this note to the documentation of previous Python versions? (e.g. Python 3.12) By the way, side-question regarding naming: Doesn't |
>>> from pathlib import PurePath
>>> PurePath('foo/bar.py').match('*.py')
True
>>> PurePath('foo/bar.py').full_match('*.py')
False It's analogous to Support for recursive |
I see now. Thank you for detailed explanations and for documenting! |
No worries, thank you very much for the report :) |
Bug report
Bug description:
Prerequisites
Hello! I have a structure of directories as follows:
Problem
Here
Pathlib.PurePath
a/b/c/d/e
won't match with**/b/c/**
, but will match with**/c/d/**
:However,
glob
on this structure yields different results:i.e.
**/b/c/**
and**/c/d/**
will match to the named path only in recursive mode.Ideas
I'd expect pathlib.match to behave more like recursive
glob.glob
(as in prior code block) orpathlib.Path.glob
:CPython versions tested on:
3.10, 3.12
Operating systems tested on:
Linux, macOS
Linked PRs
PurePath.match()
#118713The text was updated successfully, but these errors were encountered: