os.path.normcase rationale?

Ethan Furman ethan at stoneleaf.us
Mon Sep 20 22:39:21 EDT 2010


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"?

Well, if it were me, it would be either the filesystem in the path 
that's being norm'ed, or if no path is explicity stated, the filesystem 
that is hosting the current directory.

> 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
> 
> 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? 
> 
> 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? What if it's a filesystem that the normpath 
> developers haven't seen or considered before?

Something along those lines seems to be happening now.  Observe what 
happens on my XP machine with an NTFS drive.

--> import foo
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
ImportError: No module named foo
--> import FOO
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
ImportError: No module named FOO
--> import fOo
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
ImportError: No module named fOo
--> import Foo
Foo has been imported!

~Ethan~



More information about the Python-list mailing list