Skip to content

Commit 80ac11f

Browse files
author
Yury Selivanov
committed
docs: Improve docs for os.path.commonprefix
1 parent d61714d commit 80ac11f

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

Doc/library/os.path.rst

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,21 @@ the :mod:`glob` module.)
8282

8383
Return the longest path prefix (taken character-by-character) that is a
8484
prefix of all paths in *list*. If *list* is empty, return the empty string
85-
(``''``). Note that this may return invalid paths because it works a
86-
character at a time. To obtain a valid path, see :func:`commonpath`.
85+
(``''``).
86+
87+
.. note::
88+
89+
This function may return invalid paths because it works a
90+
character at a time. To obtain a valid path, see
91+
:func:`commonpath`.
92+
93+
::
94+
95+
>>> os.path.commonprefix(['/dir1/dir2', '/dir3/dir4'])
96+
'/dir'
97+
98+
>>> os.path.commonpath(['/dir1/dir2', '/dir3/dir4'])
99+
'/'
87100

88101

89102
.. function:: dirname(path)

0 commit comments

Comments
 (0)