[Python-ideas] os.path.commonpath()

Bruce Leban bruce at leapyear.org
Wed Nov 7 07:05:58 CET 2012


On Tue, Nov 6, 2012 at 9:15 PM, Greg Ewing <greg.ewing at canterbury.ac.nz>wrote:

> Bruce Leban wrote:
>
>  If you change the semantics so that it either (1) it always always
>> includes a trailing / or (2) it includes a trailing slash if the two paths
>> have it in common, then you don't have the weirdness that in this case it
>> returns a slash and in others it doesn't. I am slightly inclined to (1) at
>> this point.
>>
>
> But then the common prefix of "/a/b" and "/a/c" would be "/a/",
> which would be very unexpected -- usually the dirname of a path is
> not considered to include a trailing slash.
>

Although less confusing than the current behavior :-)

>
> The special treatment of the root directory is no weirder than it
> is anywhere else. It's already special, since in unix it's the
> only case where a trailing slash is semantically significant.
> (To the kernel, at least -- a few command line utilities break this
> rule, but they're screwy.)


That's reasonable. Perhaps it's sufficient to document it clearly.

--- Bruce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20121106/3bf5ba5f/attachment.html>


More information about the Python-ideas mailing list