ID EN
OS Path

commonpath

Python 3.11

Return the longest common sub-path of each pathname in the sequence paths. Raise ValueError if paths contain both absolute and relative pathnames, the paths are on the different drives or if paths is empty. Unlike commonprefix(), this returns a valid path.

Syntax

PYTHON
os.path.commonpath(paths)

See Also

ValueError commonprefix() Availability path-like objects