bpo-36898: Add parameter @case_sensitive to glob and rglob in pathlib by monchin · Pull Request #13274 · python/cpython
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