[Python-Dev] os.path.commonprefix (original) (raw)

Armin Rigo arigo@tunes.org
Sat, 7 Dec 2002 08:02:18 -0800 (PST)


Hello everybody,

I recently discovered that os.path.commonprefix(list-of-strings) returns the longest substring that is an initial segment of all the given strings, and that this has nothing to do with the fact that the strings might be paths. I wonder why this has been put in os.path and not in the string module in the first place. This location misled me for a long time into thinking that commonprefix() would return the longest common path, a feature whose interest I could see. But:

commonprefix(['/home/users/arigo', '/home/users/alal']) '/home/users/a'

What is the use for such a thing ??

I suggest that a more descriptive comment be added in the documentation.

Armin