2. Use explicit case sensitivity in pathlib globbing
When matching paths across platforms, use explicit case sensitivity when that behavior matters.
Path matching behavior can otherwise vary quietly across operating systems, which makes cross-platform bugs easy to miss. Being explicit documents the intended matching rule instead of leaving it to platform defaults.
Note
Python 3.12+
2.1. Don’t do this
1matches = list(Path('.').glob('*.TXT'))
2.2. Do this
1from pathlib import Path
2
3matches = list(Path('.').glob('*.TXT', case_sensitive=True))