[Tutor] Case Insensitive Globing

eryk sun eryksun at gmail.com
Sun May 19 18:36:38 EDT 2019


On 5/19/19, Alan Gauld via Tutor <tutor at python.org> wrote:
>
> Hmm, odd. My NTFS filesystems on Windows all appear to be case
> sensitive. For example I have a photo editor that saves its files
> with a jpg extension but the files from my camera all end in JPG.
> So I always end up with two copies - the original file and the
> edited version.
>
> I'm not aware of having done anything to cause that.
> More investigation required I think...

Maybe you have Explorer configured to hide file extensions, and you
have one file named "filename.JPG" and another named
"filename.jpg.JPG".

On a related note, the new support for case-sensitive directories in
Windows 10 can lead to an issue when running commands. Shells use the
PATHEXT environment variable to supply a list of default extensions
when searching PATH for a command. These are usually upper case, so if
we run "script" and it searches for "script.PY", it won't find
"script.py" in a case-sensitive directory. The same applies to
Python's shutil.which().

Regarding this topic, glob.py and fnmatch.py are unreliable in Windows
for case-sensitive NTFS directories. Sometimes they rely on regular
expressions and os.path.normcase (for ntpath.normcase, this replaces
slash with backslash and converts to lowercase), and sometimes they
rely on stat-based functions such as os.path.lexists, which will be
case sensitive.


More information about the Tutor mailing list