--- a/Doc/library/os.path.rst Sat Jul 12 18:26:03 2014 +0300
+++ b/Doc/library/os.path.rst Sun Jul 13 21:30:38 2014 +0300
@@ -66,11 +66,24 @@
empty string (``''``).
+.. function:: commonpath(paths)
+ Return the longest common sub-path of each pathname in the sequence
+ *paths*. Raise ValueError if *paths* contains both absolute and relative
+ pathnames, or if *paths* is empty. Unlike :func:`commonprefix`, this
+ returns a valid path.
+ Availability: Unix, Windows
+ .. versionadded:: 3.5
.. function:: commonprefix(list)
- 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.
+ 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`.
.. function:: dirname(path)
« no previous file with comments
« no previous file
Lib/ntpath.py » ('j')
no next file with comments »
Issue 10395: new os.path function to extract common prefix based on path components
Created 6 years, 10 months ago by Ronald Oussoren
Modified 5 years, 2 months ago
Reviewers: storchaka_gmail.com, rafik, eric.araujo
Base URL: None