[Python-Dev] A wart which should have been repaired in 3.0? (original) (raw)

Phillip J. Eby pje at telecommunity.com
Tue Dec 30 02:02:07 CET 2008


You know, all this path separator and list complication isn't really necessary, when you can just take the os.path.dirname() of the return from commonprefix().

Perhaps we could just add that recommendation to the docs?

At 04:46 PM 12/29/2008 -0600, skip at pobox.com wrote:

Jeff> For those that prefer not to add functions all willy-nilly, would Jeff> it not be better to add a "delimiter" keyword that defaults to Jeff> False? Then "delimiter=False" will function with the current Jeff> functionality unchanged while

Jeff> os.path.commonprefix(["bob/export/home", "bob/etc/passwd"], delimiter = "/") Jeff> would properly return Jeff> 'bob/' On Windows what would you do with this crazy, but valid, path? c:/etc\passwd I don't do Windows, so don't have any idea if there is even an /etc/passwd file on Windows. I'd guess not, but that's not the point. The point is that you can use both / (aka ntpath.sep) and \ (aka ntpath.altsep) in Windows pathnames. See my patch (issue 4755) for a version of os.path. which works as at least I expect and should work cross-platform. Skip


Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/pje%40telecommunity.com



More information about the Python-Dev mailing list