On this page
posixpath.commonpath
Prev: posixpath.basename | Up: posixpath | Next: posixpath.commonprefix
Rel: posixpath.abspath, posixpath.basename, posixpath.commonprefix, posixpath.dirname
Ref: docs.python.org — posixpath.commonpath
Tags: #public #python3 #stdlib #posixpath
Import
import posixpath
from posixpath import commonpath
Signature & Overview
posixpath.commonpath(paths)
Given a sequence of path names, returns the longest common sub-path.
Usage
import posixpath
assert posixpath.commonpath(['/usr/lib', '/usr/local']) == '/usr'
Gotchas
- Segment-aware: Always prefer over
commonprefix().
REPL Inspect
from posixpath import commonpath
help(commonpath)
Linked from
- tuts/python3/stdlib_module/posixpath
- tuts/python3/stdlib_module/posixpath/abspath
- tuts/python3/stdlib_module/posixpath/basename
- tuts/python3/stdlib_module/posixpath/commonprefix
- tuts/python3/stdlib_module/posixpath/dirname
- tuts/python3/stdlib_module/posixpath/exists
- tuts/python3/stdlib_module/posixpath/expanduser
- tuts/python3/stdlib_module/posixpath/expandvars
- tuts/python3/stdlib_module/posixpath/getatime
- tuts/python3/stdlib_module/posixpath/getctime
- tuts/python3/stdlib_module/posixpath/getmtime
- tuts/python3/stdlib_module/posixpath/getsize
- tuts/python3/stdlib_module/posixpath/isabs
- tuts/python3/stdlib_module/posixpath/isdevdrive
- tuts/python3/stdlib_module/posixpath/isdir
- tuts/python3/stdlib_module/posixpath/isfile
- tuts/python3/stdlib_module/posixpath/isjunction
- tuts/python3/stdlib_module/posixpath/islink
- tuts/python3/stdlib_module/posixpath/ismount
- tuts/python3/stdlib_module/posixpath/join
- tuts/python3/stdlib_module/posixpath/lexists
- tuts/python3/stdlib_module/posixpath/normcase
- tuts/python3/stdlib_module/posixpath/normpath
- tuts/python3/stdlib_module/posixpath/realpath
- tuts/python3/stdlib_module/posixpath/relpath
- tuts/python3/stdlib_module/posixpath/samefile
- tuts/python3/stdlib_module/posixpath/sameopenfile
- tuts/python3/stdlib_module/posixpath/samestat
- tuts/python3/stdlib_module/posixpath/split
- tuts/python3/stdlib_module/posixpath/splitdrive
- tuts/python3/stdlib_module/posixpath/splitext
- tuts/python3/stdlib_module/posixpath/splitroot
Related notes
- tuts/python3/stdlib_module/posixpath/abspath Linked here; links to this page; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/basename Linked here; links to this page; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/commonprefix Linked here; links to this page; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/dirname Linked here; links to this page; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/posixpath/exists links to this page; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/expanduser links to this page; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/expandvars links to this page; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/getatime links to this page; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/getctime links to this page; shared tags: #posixpath, #stdlib