genericpath.commonprefix
Up: genericpath | Next: genericpath.exists
Rel: genericpath.exists, genericpath.getatime, genericpath.getctime, genericpath.getmtime
Ref: docs.python.org — genericpath.commonprefix
Tags: #public #python3 #stdlib #genericpath
Import
import genericpath
from genericpath import commonprefix
Signature & Overview
genericpath.commonprefix(m)
Given a list of pathnames, returns the longest common leading component
Usage
import genericpath
# Character-by-character prefix (NOT path-segment aware!)
assert genericpath.commonprefix(["/usr/lib", "/usr/local"]) == "/usr/l"
Gotchas
- Use
os.path.commonpath()for filesystem paths:commonprefix()splits mid-directory name ("/usr/l").
REPL Inspect
from genericpath import commonprefix
help(commonprefix)
Linked from
- tuts/python3/stdlib_module/genericpath
- tuts/python3/stdlib_module/genericpath/exists
- tuts/python3/stdlib_module/genericpath/getatime
- tuts/python3/stdlib_module/genericpath/getctime
- tuts/python3/stdlib_module/genericpath/getmtime
- tuts/python3/stdlib_module/genericpath/getsize
- tuts/python3/stdlib_module/genericpath/isdevdrive
- tuts/python3/stdlib_module/genericpath/isdir
- tuts/python3/stdlib_module/genericpath/isfile
- tuts/python3/stdlib_module/genericpath/isjunction
- tuts/python3/stdlib_module/genericpath/islink
- tuts/python3/stdlib_module/genericpath/lexists
- tuts/python3/stdlib_module/genericpath/samefile
- tuts/python3/stdlib_module/genericpath/sameopenfile
- tuts/python3/stdlib_module/genericpath/samestat
Related notes
- tuts/python3/stdlib_module/genericpath/exists Linked here; links to this page; shared tags: #genericpath, #stdlib
- tuts/python3/stdlib_module/genericpath/getatime Linked here; links to this page; shared tags: #genericpath, #stdlib
- tuts/python3/stdlib_module/genericpath/getctime Linked here; links to this page; shared tags: #genericpath, #stdlib
- tuts/python3/stdlib_module/genericpath/getmtime Linked here; links to this page; shared tags: #genericpath, #stdlib
- tuts/python3/stdlib_module/genericpath Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/genericpath/getsize links to this page; shared tags: #genericpath, #stdlib
- tuts/python3/stdlib_module/genericpath/isdevdrive links to this page; shared tags: #genericpath, #stdlib
- tuts/python3/stdlib_module/genericpath/isdir links to this page; shared tags: #genericpath, #stdlib
- tuts/python3/stdlib_module/genericpath/isfile links to this page; shared tags: #genericpath, #stdlib
- tuts/python3/stdlib_module/genericpath/isjunction links to this page; shared tags: #genericpath, #stdlib