[Python-Dev] Re: os.path.commonprefix breakage

Greg Ewing greg@cosc.canterbury.ac.nz
Thu, 17 Aug 2000 16:28:19 +1200 (NZST)


Skip:

> Also, should the behavior be
> consistent across platforms or should it do what is correct for each
> platform on which it's implemented (dospath, ntpath, macpath)?

Obviously it should do what's correct for each platform,
although more than one thing can be correct for a
given platform -- e.g Unix doesn't care whether there's a
trailing slash on a pathname.

In the Unix case it's probably less surprising if the trailing
slash is removed, because it's redundant.

The "broken" code referred to in the original message highlights
another problem, however: there is no platform-independent way
provided to remove a prefix from a pathname, given the prefix
as returned by one of the other platform-independent path
munging functions.

So maybe there should be an os.path.removeprefix(prefix, path)
function.

While we're on the subject, another thing that's missing is
a platform-independent way of dealing with the notion of
"up one directory".

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg@cosc.canterbury.ac.nz	   +--------------------------------------+