Summary
commonprefix is a string comparison, not a path comparison:
commonprefix(['/usr/lib', '/usr/local/lib']) → '/usr/l' (string prefix; not a valid directory)
commonpath(['/usr/lib', '/usr/local/lib']) → '/usr' (valid path)
If a user is importing from os.path there is a 99.99% chance they want a path function not a string function.
commonpath was added in Python 3.5 to fix this odd commonprefix behavior: python/cpython#54604
Summary
commonprefixis a string comparison, not a path comparison:commonprefix(['/usr/lib', '/usr/local/lib'])→'/usr/l'(string prefix; not a valid directory)commonpath(['/usr/lib', '/usr/local/lib'])→'/usr'(valid path)If a user is importing from
os.paththere is a 99.99% chance they want a path function not a string function.commonpathwas added in Python 3.5 to fix this oddcommonprefixbehavior: python/cpython#54604