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