[Python-Dev] Alternative path suggestion
Greg Ewing
greg.ewing at canterbury.ac.nz
Sat May 6 13:02:28 CEST 2006
Nick Coghlan wrote:
> So I suggest splitting the internal data into 'path elements separated
> by os.sep', 'name elements separated by os.extsep'
What bothers me about that is that in many systems
there isn't any formal notion of an "extension",
just a convention used by some applications.
Just because I have a "." in my filename doesn't
necessarily mean I intend what follows to be
treated as an extension.
> assert pth.basepath == HOMEDIR
> assert pth.dirparts == ('foo', 'bar')
> assert pth.nameparts == ('baz', 'tar', 'gz')
What if one of the dirparts contains a character
happening to match os.extsep? When you do
pth2 = pth[:-1], does it suddenly get split up
into multiple nameparts, even though it's actually
naming a directory rather than a file?
(This is not hypothetical -- it's a common convention
in some unix systems to use names like "spam.d" for
directories of configuration files.)
--
Greg
More information about the Python-Dev
mailing list