[Python-Dev] commonprefix - the beast just won't die... (original) (raw)

Thomas Wouters thomas@xs4all.net
Tue, 22 Aug 2000 17:16:38 +0200


On Tue, Aug 22, 2000 at 09:45:27AM -0500, Skip Montanaro wrote:

I reverted the changes to {posix,nt,dos}path.commonprefix this morning, updated the tests (still to be checked in) and was starting to work on documentation changes, when I realized that something Guido said about using dirname to trim to the common directory prefix is probably not correct. Here's an example. The common prefix of ["/usr/local", "/usr/local/bin"] is "/usr/local". If you blindly apply dirname to that (which is what I think Guido suggested as the way to make commonprefix do what I wanted, you wind up with "/usr", which isn't going to be correct on most Unix flavors. Instead, you need to check that the prefix doesn't exist or isn't a directory before applying dirname.

And even that won't work, in a case like this:

/home/swenson/ /home/swen/

(common prefix would be /home/swen, which is a directory) or cases like this:

/home/swenson/ /home/swenniker/

where another directory called /home/swen

exists.

-- Thomas Wouters <thomas@xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!