Filename case-insensitivity on OS X
Tom Anderson
twic at urchin.earth.li
Tue Jan 3 21:47:28 EST 2006
On Tue, 3 Jan 2006, Scott David Daniels wrote:
> Tom Anderson wrote:
>
>> Java has a java.io.File.getCanonicalPath method that does this, but i can't
>> find an equivalent in python - is there one?
>
> What's wrong with: os.path.normcase(path) ?
It doesn't work.
Hooke:~ tom$ uname
Darwin
Hooke:~ tom$ python
Python 2.4.1 (#2, Mar 31 2005, 00:05:10)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> path=os.path.join(".", os.listdir(".")[0])
>>> path
'./.appletviewer'
>>> os.path.normcase(path)
'./.appletviewer'
>>> os.path.normcase(path.upper())
'./.APPLETVIEWER'
>>>
I'm not entirely sure what normcase is supposed to do - the documentation
says "Normalize case of pathname. Has no effect under Posix", which is
less than completely illuminating.
tom
--
It involves police, bailiffs, vampires and a portal to hell under a
tower block in Hackney.
More information about the Python-list
mailing list