[Python-ideas] PEP 428 - object-oriented filesystem paths
greg.ewing at canterbury.ac.nz
Mon Oct 8 00:55:26 CEST 2012
Antoine Pitrou wrote:
> On Sun, 7 Oct 2012 22:43:02 +0100
> Arnaud Delobelle <arnodel at gmail.com>
>>Naive question: how do you deal with HFS+, which is case-preserving
>>but on most machines case-insensitive?
> I don't know. How does os.path deal with it?
Not all that well, apparently. From the docs for os.path:
Normalize the case of a pathname. On Unix and Mac OS X, this returns the
path unchanged; on case-insensitive filesystems, it converts the path to
lowercase. On Windows, it also converts forward slashes to backward slashes.
This is partially self-contradictory, since many MacOSX filesystems are
actually case-insensitive; it depends on the particular filesystem concerned.
Worse, different parts of the same path can have different case sensitivities.
Also, with network file systems, not all paths are necessarily case-insensitive
So there's really no certain way to compare pure paths for equality. Basing
it on which OS is running your code is no more than a guess.
More information about the Python-ideas