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

Gordon McMillan gmcm@hypernet.com
Fri, 18 Aug 2000 12:28:49 -0400


M.-A. Lemburg wrote:
> Gordon McMillan wrote:
> > 
> > M.-A. Lemburg wrote:
> > 
> > > ... just look at what your browser does
> > > when you request http://www.python.org/search ... the server
> > > redirects you to search/ to make sure that the links embedded
> > > in the page are relative to search/ and not www.python.org/.
> > 
> > While that seems to be what Apache does, I get 40x's from
> > IIS and Netscape server. Greg Ewing's demonstrated a Unix
> > where the trailing slash indicates nothing useful, Tim's
> > demonstrated that Windows gets confused by a trailing slash
> > unless we're talking about the root directory on a drive (and
> > BTW, same results if you use backslash).
> > 
> > On WIndows, os.path.commonprefix doesn't use normcase
> > and normpath, so it's completely useless anyway. (That is, it's
> > really a "string" function and has nothing to do with paths).
> 
> I still don't get it: what's the point in carelessly dropping
> valid and useful information for no obvious reason at all ?

I wasn't advocating anything. I was pointing out that it's not 
necessarily "valid" or "useful" information in all contexts.
 
> Besides the previous behaviour was documented and most probably
> used in some apps. Why break those ?

I don't think commonprefix should be changed, precisely 
because it might break apps. I also think it should not live in 
os.path, because it is not an abstract path operation. It's just 
a string operation. But it's there, so the best I can advise is 
not to use it.
 
> And last not least: what if the directory in question doesn't
> even exist anywhere and is only encoded in the path by the fact
> that there is a slash following it ?

If it doesn't exist, it's not a directory with or without a slash 
following it. The fact that Python largely successfully reuses 
os.path code to deal with URLs does not mean that the 
syntax of URLs should be mistaken for the syntax of file 
systems, even at an abstract level. At the level where 
commonprefix operates, abstraction isn't even a concept.

- Gordon