os.path.normcase rationale?

Chris Withers chris at simplistix.co.uk
Mon Sep 20 20:45:37 CEST 2010


On 15/09/2010 22:12, Ben Finney wrote:
> Chris Withers<chris at simplistix.co.uk>  writes:
>
>> I'm curious as to why, with a file called "Foo.txt"
>> os.path.normcase('FoO.txt') will return "foo.txt" rather than
>> "Foo.txt"?
>
> What kind of answer are you looking for?
>
> A direct answer would be: it does that because on case-insensitive
> filesystems, it doesn't matter what the case is, so there's no need for
> anything more complex than all lowercase.

Well, no, that doesn't feel right. Normalisation of case, for me, means 
"give me the case as the filesystem thinks it should be", not "just 
lowercase it all". This makes a difference; I hit it by way of version 
pinning in buildout, the culprit being setuptools calling normcase on 
distributions found on the filesystem on Windows. Buildout's version 
pinning is case sensitive (arguably a bug) and so doesn't work when 
setuptools's use of normcase ends up with he distribution name being 
lowercased, even though the case is correct on the file system...

>> Yes, I know the behaviour is documented
>
> The docstring is fairly poor, IMO. You might want to submit a bug report
> to improve it.

I think it would have been a lot more confusing had it not been 
mentioned that it was just lowercasing everything...

Chris

-- 
Simplistix - Content Management, Batch Processing & Python Consulting
             - http://www.simplistix.co.uk



More information about the Python-list mailing list