Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(85556)

Side by Side Diff: Doc/library/os.path.rst

Issue 10395: new os.path function to extract common prefix based on path components
Patch Set: Created 6 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Lib/posixpath.py » ('j') | Lib/posixpath.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 :mod:`os.path` --- Common pathname manipulations 1 :mod:`os.path` --- Common pathname manipulations
2 ================================================ 2 ================================================
3 3
4 .. module:: os.path 4 .. module:: os.path
5 :synopsis: Operations on pathnames. 5 :synopsis: Operations on pathnames.
6 6
7 .. index:: single: path; operations 7 .. index:: single: path; operations
8 8
9 This module implements some useful functions on pathnames. To read or 9 This module implements some useful functions on pathnames. To read or
10 write files see :func:`open`, and for accessing the filesystem see the 10 write files see :func:`open`, and for accessing the filesystem see the
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 from the Unix :program:`basename` program; where :program:`basename` for 52 from the Unix :program:`basename` program; where :program:`basename` for
53 ``'/foo/bar/'`` returns ``'bar'``, the :func:`basename` function returns an 53 ``'/foo/bar/'`` returns ``'bar'``, the :func:`basename` function returns an
54 empty string (``''``). 54 empty string (``''``).
55 55
56 56
57 .. function:: commonprefix(list) 57 .. function:: commonprefix(list)
58 58
59 Return the longest path prefix (taken character-by-character) that is a prefi x 59 Return the longest path prefix (taken character-by-character) that is a prefi x
60 of all paths in *list*. If *list* is empty, return the empty string (``''`` ). 60 of all paths in *list*. If *list* is empty, return the empty string (``''`` ).
61 Note that this may return invalid paths because it works a character at a tim e. 61 Note that this may return invalid paths because it works a character at a tim e.
62
63 .. function:: commonpath(paths)
64
65 Return the longest common sub-path of each pathname in the sequence
66 *paths*. The paths must be absolute, otherwise a ValueError is raised.
67 If *paths* is empty, return ``None``. If each path ends with a path
68 separator, the returned sub-path will also end with a separator, otherwise
69 it will not. Unlike :func:`commonprefix`, this returns a valid path.
70
71 Availability: Unix.
72
73 .. versionadded:: 3.4
62 74
63 75
64 .. function:: dirname(path) 76 .. function:: dirname(path)
65 77
66 Return the directory name of pathname *path*. This is the first half of the 78 Return the directory name of pathname *path*. This is the first half of the
67 pair returned by ``split(path)``. 79 pair returned by ``split(path)``.
68 80
69 81
70 .. function:: exists(path) 82 .. function:: exists(path)
71 83
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 the path (such as ``r'\path\file.ext'``). For paths containing drive letter s, 332 the path (such as ``r'\path\file.ext'``). For paths containing drive letter s,
321 *unc* will always be the empty string. 333 *unc* will always be the empty string.
322 334
323 Availability: Windows. 335 Availability: Windows.
324 336
325 337
326 .. data:: supports_unicode_filenames 338 .. data:: supports_unicode_filenames
327 339
328 True if arbitrary Unicode strings can be used as file names (within limitatio ns 340 True if arbitrary Unicode strings can be used as file names (within limitatio ns
329 imposed by the file system). 341 imposed by the file system).
OLDNEW
« no previous file with comments | « no previous file | Lib/posixpath.py » ('j') | Lib/posixpath.py » ('J')

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+