Repository navigation
Add parameter @case_sensitive to glob and rglob in pathlib #81079
Description
Activity
In pathlib, I add a parameter @case_sensitive to glob and rglob.
Sometimes the extension would be in upper case but sometimes it would be lower case, for example: *.tif and *.TIF. So the parameter @case_sensitive may be useful in some cases.
Usage example:
In [1]: from pathlib import PathIn [2]: path = Path('.')
In [3]: for each_file in path.glob('*.tif'):
...: print(each_file)
...:
a.tif
b.tifIn [4]: for each_file in path.rglob('*.TIF'):
...: print(each_file)
...:
c.TIF
TEST/d.TIFIn [5]: for each_file in path.glob('*.TIF', case_sensitive=False):
...: print(each_file)
...:
a.tif
c.TIF
b.tifIn [6]: for each_file in path.rglob('*.TIF', case_sensitive=False):
...: print(each_file)
...:
a.tif
c.TIF
b.tif
TEST/d.TIF
TEST/e.tif- added3.7 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
on May 13, 2019 You can use the pattern '*.[Tt][Ii][Ff]'.
It is a good solution but when pattern is long, it might be a little inconvenient.
Anyway, just an advice. Thank you for your reply!This should be straightforward to add once #102616 lands.
- added a commit that references this issue
on Mar 15, 2023 PR available: #102710
- added 6 commits that reference this issue
on Apr 29, 2023 - added a commit that references this issue
on May 5, 2023
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs
pathlib.Path.glob()#102710