[Python-ideas] commonprefix

2024-06-12 Thread Rob Cliffe via Python-ideas
The os.path.commonprefix function basically returns the common initial characters (if any) shared by a sequence of strings, e.g.     os.path.commonprefix(("Python is great!", "Python is not bad", "Python helps")) # returns "Python " This is purely a string manipulation function which bears no rel

[Python-ideas] Re: commonprefix

2024-06-12 Thread Tim Peters
[Rob Cliffe] > The os.path.commonprefix function basically returns the common initial > characters (if any) shared by a sequence of strings, e.g. > ... > It seems to me that this function (or something similar) should not be > in os.path, but somewhere else where it would be more visible. It's ce

[Python-ideas] Re: commonprefix

2024-06-12 Thread Dom Grigonis
This being in `os.path` module suggests that the main intent is to find a common prefix of a `path`. If this is the case, maybe it would be worth instead of: ``` if not isinstance(m[0], (list, tuple)): m = tuple(map(os.fspath, m)) ``` have ``` if not isinstance(m[0], (list, tuple)):