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

Greg Ewing greg@cosc.canterbury.ac.nz
Fri, 18 Aug 2000 13:52:32 +1200 (NZST)


Skip:

> Since we already have os.path.commonprefix and it's not going away,

If it's to stay the way it is, we need another function to
do what it should have been designed to do in the first place.
That means two new functions, one to find a common prefix,
and one to remove a given prefix.

But it's not clear exactly what a function such as

   removeprefix(prefix, path)

should do. What happens, for instance, if 'prefix' is not actually a
prefix of 'path', or only part of it is a prefix?

A reasonable definition might be that however much of 'prefix' is
a prefix of 'path' is removed. But that requires finding the common
prefix of the prefix and the path, which is intruding on commonprefix's 
territory!

This is what led me to think of combining the two operations
into one, which would have a clear, unambiguous definition
covering all cases.

> there's nothing in the name factorize that suggests that it would
> split the paths at the common prefix.

I'm not particularly attached to that name. Call it
'splitcommonprefix' or something if you like.

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	   +--------------------------------------+