os.path.normcase rationale?

Chris Withers chris at simplistix.co.uk
Fri Sep 24 10:28:47 CEST 2010

On 21/09/2010 01:02, Steven D'Aprano wrote:
> On Mon, 20 Sep 2010 19:45:37 +0100, Chris Withers wrote:
>> Well, no, that doesn't feel right. Normalisation of case, for me, means
>> "give me the case as the filesystem thinks it should be",
> What do you mean "the filesystem"?
> If I look at the available devices on my system now, I see:
> 2 x FAT-32 filesystems
> 1 x ext2 filesystem
> 3 x ext3 filesystems
> 1 x NTFS filesystem
> 1 x UDF filesystem

Right, and each of these will know what it thinks a file's "real" name 
is, along with potentially accepting as set of synonyms for them...

> and if I ever get my act together to install Basilisk II, as I've been
> threatening to do for the last five years, there will also be at least
> one 1 x HFS filesystem. Which one is "the" filesystem?

Whichever one you're getting the file from...

> If you are suggesting that os.path.normcase(filename) should determine
> which filesystem actually applies to filename at runtime, and hence work
> out what rules apply, what do you suggest should happen if the given path
> doesn't actually exist?

I'd suggest an exception be raised.
Really, what's the point of normcase if it's basically just
"if os=='win': return path.lower()"

> What if it's a filesystem that the normpath
> developers haven't seen or considered before?

I didn't say it was an easy problem, but the current normpath is a waste 
of space...


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

More information about the Python-list mailing list