On this page
  1. genericpath.commonprefix
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

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

REPL Inspect

from genericpath import commonprefix
help(commonprefix)

Linked from

Related notes