[Python-ideas] os.path.commonprefix: Yes that old chestnut.

Paddy3118 paddy3118 at gmail.com
Sat Mar 21 05:41:03 CET 2015


I had to add a comment to an RC entry 
<http://rosettacode.org/wiki/Longest_common_prefix#Python>that was using 
os.path.commonprefix to compute the longest common prefix which it does 
regardless of path separators, (which is what it should do).

It has been discussed before <http://bugs.python.org/issue10395>- it goes 
back to the nineties it seems, but we are still left with a misplaced 
function, (it should be str.commonprefix), with an awful hack of saying 
"yes we know its ballsed up" in the documentation 
<https://docs.python.org/3.5/library/os.path.html?highlight=commonprefix#os.path.commonprefix>
.

I guess we missed a great opportunity to fix this when we moved to Python 3 
too!?

The  fix seems clear: deprecate os.path.commonprefix whilst creating a true 
os.path.commonpath and str.commonprefix. The deprecated function should 
hang around and the standard libs modified to switch to the new function(s)

I've heard that some religious people put obvious faults in their work as 
only their god should get so close to perfection - maybe that's why we 
still have this wart :-)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150320/72c5f132/attachment.html>


More information about the Python-ideas mailing list