Comments (7)
Recursive expansion isn't supported, and so
**
wildcards work exactly like*
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 full_match
sound more strict than just match
? :)
full_match
seems more relaxed than the regular match, because of allowing for recursive patterns to be used, thus allowing more matches per recursive glob.
from cpython.
By the way, side-question regarding naming: Doesn't
full_match
sound more strict than justmatch
? :)full_match
seems more relaxed than the regular match, because of allowing for recursive patterns to be used, thus allowing more matches per recursive glob.
full_match()
matches against the entire path, whereas match()
matches from the right, so:
>>> from pathlib import PurePath
>>> PurePath('foo/bar.py').match('*.py')
True
>>> PurePath('foo/bar.py').full_match('*.py')
False
It's analogous to re.match()
vs re.fullmatch()
.
Support for recursive **
wildcards only really makes sense once you eliminate the right-hand-side matching, otherwise all your patterns have an implicit **/
prefix, which makes it much less useful.
from cpython.
No worries, thank you very much for the report :)
from cpython.
Follow-up: May be connected with #106747
from cpython.
cc @barneygale
from cpython.
PurePath.match()
has a couple of important differences from Path.glob()
and glob.glob()
:
- Recursive expansion isn't supported, and so
**
wildcards work exactly like*
- If a relative pattern is given, matching is performed from the right
Could you try using Path.full_match()
in an alpha or (upcoming) beta of 3.13? I think it does what you want:
>>> import pathlib
>>> path = pathlib.PurePath("a/b/c/d/e")
>>> path.full_match("**/b/c/**")
True
>>> path.full_match("**/c/d/**")
True
from cpython.
I see now.
Thank you for detailed explanations and for documenting!
from cpython.
Related Issues (20)
- Remove `sqlite3.version` and `sqlite3.version_info`
- GC may have inconsistent view of stacktop with deferred references
- sqlite3: disallow using a sequence of params with named placeholders
- How to handle DECREF_INPUTS_AND_REUSE_FLOAT with deferred floats?
- ChainMap.__contains__ and .get performance improvement. HOT 10
- `PyEval_GetLocals()` leaks locals HOT 1
- Default argument for `__getitem__()` HOT 2
- Python-3.13.0b1 changes behavior on exec() versus Python-3.12 and before ... is it normal ? HOT 6
- uClibc-ng support? HOT 1
- `jit.c` may be built with an incomplete `jit_stencils.h` HOT 4
- Contextvars + async generator + break + finally HOT 3
- Add ISO Basic format support to datetime.isoformat() and date.isoformat() HOT 2
- `asyncio.sslproto._SSLProtocolTransport` can experience invalid state, leading to silent failures. HOT 3
- improvement suggestion for the Coordinate exemple in 3/howto/enum.html HOT 1
- wont let me install because i "cancelled installation"
- Group definition of `os.remove()` & `os.unlink()`
- random.choices undefined behavior when some weights are not finite or negative HOT 2
- Support sharing `NotImplemented` singletons in subinterpreters
- SBOM invalid in https://github.com/python/cpython/blob/main/Misc/sbom.spdx.json HOT 8
- translation error in fr/3/library/argparse.html HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpython.