]> granicus.if.org Git - python/commitdiff
docs: Improve docs for os.path.commonprefix
authorYury Selivanov <yselivanov@sprymix.com>
Tue, 18 Aug 2015 03:43:43 +0000 (23:43 -0400)
committerYury Selivanov <yselivanov@sprymix.com>
Tue, 18 Aug 2015 03:43:43 +0000 (23:43 -0400)
Doc/library/os.path.rst

index e4fe44ed94fd8b6cf44dc33f03c49344343bdd04..041277cd9c85aa3f34e720ec4ecc0c8ee0ef4c0c 100644 (file)
@@ -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)