[Python-Dev] os.path.normcase rationale?

Guido van Rossum guido at python.org
Sun Sep 19 00:36:58 CEST 2010

On Sat, Sep 18, 2010 at 2:39 PM, Chris Withers <chris at simplistix.co.uk> wrote:
> I'm curious as to why, with a file called "Foo.txt" on a case descriminating
> but case insensitive filesystem, os.path.normcase('FoO.txt') will return
> "foo.txt" rather than "Foo.txt"?
> Yes, I know the behaviour is documented, but I'm wondering if anyone can
> remember the rationale for that behaviour?

Because normcase() and friends never look at the filesystem. Of
course, exists() and isdir() etc. do, and so does realpath(), but the
pure parsing functions don't. They can be used without a working
filesystem even. (E.g. you can import ntpath on a Unix box and happily
parse Windows paths.)

--Guido van Rossum (python.org/~guido)

More information about the Python-Dev mailing list