OLD | NEW |
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 Loading... |
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 Loading... |
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). |
OLD | NEW |