[New-bugs-announce] [issue36898] Add parameter @case_sensitive to glob and rglob in pathlib
Chuang Men
report at bugs.python.org
Mon May 13 03:17:56 EDT 2019
New submission from Chuang Men <pazzinter921217 at gmail.com>:
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 Path
In [2]: path = Path('.')
In [3]: for each_file in path.glob('*.tif'):
...: print(each_file)
...:
a.tif
b.tif
In [4]: for each_file in path.rglob('*.TIF'):
...: print(each_file)
...:
c.TIF
TEST/d.TIF
In [5]: for each_file in path.glob('*.TIF', case_sensitive=False):
...: print(each_file)
...:
a.tif
c.TIF
b.tif
In [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
----------
components: Library (Lib)
files: pathlib.py
messages: 342284
nosy: Chuang Men
priority: normal
severity: normal
status: open
title: Add parameter @case_sensitive to glob and rglob in pathlib
type: enhancement
versions: Python 3.7
Added file: https://bugs.python.org/file48328/pathlib.py
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36898>
_______________________________________
More information about the New-bugs-announce
mailing list