[Python-Dev] A wart which should have been repaired in 3.0?

Scott David Daniels Scott.Daniels at Acm.Org
Mon Dec 29 23:02:20 CET 2008


Jeff Hall wrote:
>... For those that prefer not to add functions all willy-nilly, would it not 
> be better to add a "delimiter" keyword that defaults to False? Then 
> "delimiter=False" will function with the current functionality unchanged 
> while
> 
> os.path.commonprefix(["bob/export/home", "bob/etc/passwd"], delimiter = 
> "/")

The proper call should be:
os.path.commonprefix(["bob/example", "bob/etc/passwd"], delimiter=True)

and output:
        'bob'   (path to the common directory)

Perhaps even call the keyword arg "delimited," rather than "delimiter."
On Windows, I'd like to see:
   os.path.commonprefix(['a/b/c.d/e'f', r'a\b\c.d\eve'], delimited=True)
return either
      'a/b/c.d'
  or  r'a\b\c.d'
Perhaps even ['a', 'b', 'c.d'] (suitable for os.path.join).

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-Dev mailing list