mirror of
https://github.com/python/cpython.git
synced 2025-09-28 19:25:27 +00:00
docs: Improve docs for os.path.commonprefix
This commit is contained in:
parent
d61714d236
commit
80ac11f95f
1 changed files with 15 additions and 2 deletions
|
@ -82,8 +82,21 @@ the :mod:`glob` module.)
|
|||
|
||||
Return the longest path prefix (taken character-by-character) that is a
|
||||
prefix of all paths in *list*. If *list* is empty, return the empty string
|
||||
(``''``). Note that this may return invalid paths because it works a
|
||||
character at a time. To obtain a valid path, see :func:`commonpath`.
|
||||
(``''``).
|
||||
|
||||
.. note::
|
||||
|
||||
This function may return invalid paths because it works a
|
||||
character at a time. To obtain a valid path, see
|
||||
:func:`commonpath`.
|
||||
|
||||
::
|
||||
|
||||
>>> os.path.commonprefix(['/dir1/dir2', '/dir3/dir4'])
|
||||
'/dir'
|
||||
|
||||
>>> os.path.commonpath(['/dir1/dir2', '/dir3/dir4'])
|
||||
'/'
|
||||
|
||||
|
||||
.. function:: dirname(path)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue