| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 1 | :mod:`os.path` --- Common pathname manipulations | 
 | 2 | ================================================ | 
 | 3 |  | 
 | 4 | .. module:: os.path | 
 | 5 |    :synopsis: Operations on pathnames. | 
 | 6 |  | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 7 | .. index:: single: path; operations | 
 | 8 |  | 
 | 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 | 
| Martin v. Löwis | 651423c | 2008-10-07 07:03:04 +0000 | [diff] [blame] | 11 | :mod:`os` module. The path parameters can be passed as either strings, | 
 | 12 | or bytes. Applications are encouraged to represent file names as | 
 | 13 | (Unicode) character strings. Unfortunately, some file names may not be | 
 | 14 | representable as strings on Unix, so applications that need to support | 
 | 15 | arbitrary file names on Unix should use bytes objects to represent | 
 | 16 | path names. Vice versa, using bytes objects cannot represent all file | 
 | 17 | names on Windows (in the standard ``mbcs`` encoding), hence Windows | 
 | 18 | applications should use string objects to access all files. | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 19 |  | 
| R David Murray | a4e700c | 2013-01-06 16:13:10 -0500 | [diff] [blame] | 20 | Unlike a unix shell, Python does not do any *automatic* path expansions. | 
 | 21 | Functions such as :func:`expanduser` and :func:`expandvars` can be invoked | 
 | 22 | explicitly when an application desires shell-like path expansion.  (See also | 
 | 23 | the :mod:`glob` module.) | 
 | 24 |  | 
| Georg Brandl | 76e5538 | 2008-10-08 16:34:57 +0000 | [diff] [blame] | 25 | .. note:: | 
 | 26 |  | 
 | 27 |    All of these functions accept either only bytes or only string objects as | 
 | 28 |    their parameters.  The result is an object of the same type, if a path or | 
 | 29 |    file name is returned. | 
 | 30 |  | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 31 |  | 
| Benjamin Peterson | d23f822 | 2009-04-05 19:13:16 +0000 | [diff] [blame] | 32 | .. note:: | 
 | 33 |  | 
 | 34 |    Since different operating systems have different path name conventions, there | 
 | 35 |    are several versions of this module in the standard library.  The | 
 | 36 |    :mod:`os.path` module is always the path module suitable for the operating | 
 | 37 |    system Python is running on, and therefore usable for local paths.  However, | 
 | 38 |    you can also import and use the individual modules if you want to manipulate | 
 | 39 |    a path that is *always* in one of the different formats.  They all have the | 
 | 40 |    same interface: | 
 | 41 |  | 
 | 42 |    * :mod:`posixpath` for UNIX-style paths | 
 | 43 |    * :mod:`ntpath` for Windows paths | 
 | 44 |    * :mod:`macpath` for old-style MacOS paths | 
 | 45 |    * :mod:`os2emxpath` for OS/2 EMX paths | 
 | 46 |  | 
 | 47 |  | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 48 | .. function:: abspath(path) | 
 | 49 |  | 
 | 50 |    Return a normalized absolutized version of the pathname *path*. On most | 
| Chris Jerdonek | 0b502ff | 2012-11-25 20:38:01 -0800 | [diff] [blame] | 51 |    platforms, this is equivalent to calling the function :func:`normpath` as | 
 | 52 |    follows: ``normpath(join(os.getcwd(), path))``. | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 53 |  | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 54 |  | 
 | 55 | .. function:: basename(path) | 
 | 56 |  | 
| Chris Jerdonek | 0b502ff | 2012-11-25 20:38:01 -0800 | [diff] [blame] | 57 |    Return the base name of pathname *path*.  This is the second element of the | 
 | 58 |    pair returned by passing *path* to the function :func:`split`.  Note that | 
 | 59 |    the result of this function is different | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 60 |    from the Unix :program:`basename` program; where :program:`basename` for | 
 | 61 |    ``'/foo/bar/'`` returns ``'bar'``, the :func:`basename` function returns an | 
 | 62 |    empty string (``''``). | 
 | 63 |  | 
 | 64 |  | 
 | 65 | .. function:: commonprefix(list) | 
 | 66 |  | 
 | 67 |    Return the longest path prefix (taken character-by-character) that is a prefix | 
 | 68 |    of all paths in  *list*.  If *list* is empty, return the empty string (``''``). | 
 | 69 |    Note that this may return invalid paths because it works a character at a time. | 
 | 70 |  | 
 | 71 |  | 
 | 72 | .. function:: dirname(path) | 
 | 73 |  | 
| Chris Jerdonek | 0b502ff | 2012-11-25 20:38:01 -0800 | [diff] [blame] | 74 |    Return the directory name of pathname *path*.  This is the first element of | 
 | 75 |    the pair returned by passing *path* to the function :func:`split`. | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 76 |  | 
 | 77 |  | 
 | 78 | .. function:: exists(path) | 
 | 79 |  | 
| Richard Oudkerk | 2240ac1 | 2012-07-06 12:05:32 +0100 | [diff] [blame] | 80 |    Return ``True`` if *path* refers to an existing path or an open | 
 | 81 |    file descriptor.  Returns ``False`` for broken symbolic links.  On | 
 | 82 |    some platforms, this function may return ``False`` if permission is | 
 | 83 |    not granted to execute :func:`os.stat` on the requested file, even | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 84 |    if the *path* physically exists. | 
 | 85 |  | 
| Richard Oudkerk | 2240ac1 | 2012-07-06 12:05:32 +0100 | [diff] [blame] | 86 |    .. versionchanged:: 3.3 | 
 | 87 |       *path* can now be an integer: ``True`` is returned if it is an | 
 | 88 |        open file descriptor, ``False`` otherwise. | 
 | 89 |  | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 90 |  | 
 | 91 | .. function:: lexists(path) | 
 | 92 |  | 
 | 93 |    Return ``True`` if *path* refers to an existing path. Returns ``True`` for | 
 | 94 |    broken symbolic links.   Equivalent to :func:`exists` on platforms lacking | 
 | 95 |    :func:`os.lstat`. | 
 | 96 |  | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 97 |  | 
 | 98 | .. function:: expanduser(path) | 
 | 99 |  | 
 | 100 |    On Unix and Windows, return the argument with an initial component of ``~`` or | 
 | 101 |    ``~user`` replaced by that *user*'s home directory. | 
 | 102 |  | 
 | 103 |    .. index:: module: pwd | 
 | 104 |  | 
 | 105 |    On Unix, an initial ``~`` is replaced by the environment variable :envvar:`HOME` | 
 | 106 |    if it is set; otherwise the current user's home directory is looked up in the | 
 | 107 |    password directory through the built-in module :mod:`pwd`. An initial ``~user`` | 
 | 108 |    is looked up directly in the password directory. | 
 | 109 |  | 
 | 110 |    On Windows, :envvar:`HOME` and :envvar:`USERPROFILE` will be used if set, | 
 | 111 |    otherwise a combination of :envvar:`HOMEPATH` and :envvar:`HOMEDRIVE` will be | 
 | 112 |    used.  An initial ``~user`` is handled by stripping the last directory component | 
 | 113 |    from the created user path derived above. | 
 | 114 |  | 
 | 115 |    If the expansion fails or if the path does not begin with a tilde, the path is | 
 | 116 |    returned unchanged. | 
 | 117 |  | 
 | 118 |  | 
 | 119 | .. function:: expandvars(path) | 
 | 120 |  | 
 | 121 |    Return the argument with environment variables expanded.  Substrings of the form | 
 | 122 |    ``$name`` or ``${name}`` are replaced by the value of environment variable | 
 | 123 |    *name*.  Malformed variable names and references to non-existing variables are | 
 | 124 |    left unchanged. | 
 | 125 |  | 
 | 126 |    On Windows, ``%name%`` expansions are supported in addition to ``$name`` and | 
 | 127 |    ``${name}``. | 
 | 128 |  | 
 | 129 |  | 
 | 130 | .. function:: getatime(path) | 
 | 131 |  | 
 | 132 |    Return the time of last access of *path*.  The return value is a number giving | 
 | 133 |    the number of seconds since the epoch (see the  :mod:`time` module).  Raise | 
| Andrew Svetlov | 618c2e1 | 2012-12-15 22:59:24 +0200 | [diff] [blame] | 134 |    :exc:`OSError` if the file does not exist or is inaccessible. | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 135 |  | 
| Georg Brandl | 55ac8f0 | 2007-09-01 13:51:09 +0000 | [diff] [blame] | 136 |    If :func:`os.stat_float_times` returns True, the result is a floating point | 
 | 137 |    number. | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 138 |  | 
 | 139 |  | 
 | 140 | .. function:: getmtime(path) | 
 | 141 |  | 
 | 142 |    Return the time of last modification of *path*.  The return value is a number | 
 | 143 |    giving the number of seconds since the epoch (see the  :mod:`time` module). | 
| Andrew Svetlov | 618c2e1 | 2012-12-15 22:59:24 +0200 | [diff] [blame] | 144 |    Raise :exc:`OSError` if the file does not exist or is inaccessible. | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 145 |  | 
| Georg Brandl | 55ac8f0 | 2007-09-01 13:51:09 +0000 | [diff] [blame] | 146 |    If :func:`os.stat_float_times` returns True, the result is a floating point | 
 | 147 |    number. | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 148 |  | 
 | 149 |  | 
 | 150 | .. function:: getctime(path) | 
 | 151 |  | 
 | 152 |    Return the system's ctime which, on some systems (like Unix) is the time of the | 
| Georg Brandl | f632494 | 2013-10-06 09:52:55 +0200 | [diff] [blame] | 153 |    last metadata change, and, on others (like Windows), is the creation time for *path*. | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 154 |    The return value is a number giving the number of seconds since the epoch (see | 
| Andrew Svetlov | 618c2e1 | 2012-12-15 22:59:24 +0200 | [diff] [blame] | 155 |    the  :mod:`time` module).  Raise :exc:`OSError` if the file does not exist or | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 156 |    is inaccessible. | 
 | 157 |  | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 158 |  | 
 | 159 | .. function:: getsize(path) | 
 | 160 |  | 
| Andrew Svetlov | 618c2e1 | 2012-12-15 22:59:24 +0200 | [diff] [blame] | 161 |    Return the size, in bytes, of *path*.  Raise :exc:`OSError` if the file does | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 162 |    not exist or is inaccessible. | 
 | 163 |  | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 164 |  | 
 | 165 | .. function:: isabs(path) | 
 | 166 |  | 
| Christian Heimes | af98da1 | 2008-01-27 15:18:18 +0000 | [diff] [blame] | 167 |    Return ``True`` if *path* is an absolute pathname.  On Unix, that means it | 
 | 168 |    begins with a slash, on Windows that it begins with a (back)slash after chopping | 
 | 169 |    off a potential drive letter. | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 170 |  | 
 | 171 |  | 
 | 172 | .. function:: isfile(path) | 
 | 173 |  | 
 | 174 |    Return ``True`` if *path* is an existing regular file.  This follows symbolic | 
 | 175 |    links, so both :func:`islink` and :func:`isfile` can be true for the same path. | 
 | 176 |  | 
 | 177 |  | 
 | 178 | .. function:: isdir(path) | 
 | 179 |  | 
 | 180 |    Return ``True`` if *path* is an existing directory.  This follows symbolic | 
 | 181 |    links, so both :func:`islink` and :func:`isdir` can be true for the same path. | 
 | 182 |  | 
 | 183 |  | 
 | 184 | .. function:: islink(path) | 
 | 185 |  | 
 | 186 |    Return ``True`` if *path* refers to a directory entry that is a symbolic link. | 
 | 187 |    Always ``False`` if symbolic links are not supported. | 
 | 188 |  | 
 | 189 |  | 
 | 190 | .. function:: ismount(path) | 
 | 191 |  | 
 | 192 |    Return ``True`` if pathname *path* is a :dfn:`mount point`: a point in a file | 
 | 193 |    system where a different file system has been mounted.  The function checks | 
 | 194 |    whether *path*'s parent, :file:`path/..`, is on a different device than *path*, | 
 | 195 |    or whether :file:`path/..` and *path* point to the same i-node on the same | 
 | 196 |    device --- this should detect mount points for all Unix and POSIX variants. | 
 | 197 |  | 
 | 198 |  | 
 | 199 | .. function:: join(path1[, path2[, ...]]) | 
 | 200 |  | 
 | 201 |    Join one or more path components intelligently.  If any component is an absolute | 
 | 202 |    path, all previous components (on Windows, including the previous drive letter, | 
 | 203 |    if there was one) are thrown away, and joining continues.  The return value is | 
 | 204 |    the concatenation of *path1*, and optionally *path2*, etc., with exactly one | 
| R David Murray | 24eb4bc | 2011-06-23 21:26:13 -0400 | [diff] [blame] | 205 |    directory separator (``os.sep``) following each non-empty part except the last. | 
 | 206 |    (This means that an empty last part will result in a path that ends with a | 
 | 207 |    separator.)  Note that on Windows, since there is a current directory for | 
 | 208 |    each drive, ``os.path.join("c:", "foo")`` represents a path relative to the | 
 | 209 |    current directory on drive :file:`C:` (:file:`c:foo`), not :file:`c:\\foo`. | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 210 |  | 
 | 211 |  | 
 | 212 | .. function:: normcase(path) | 
 | 213 |  | 
| Benjamin Peterson | d23f822 | 2009-04-05 19:13:16 +0000 | [diff] [blame] | 214 |    Normalize the case of a pathname.  On Unix and Mac OS X, this returns the | 
 | 215 |    path unchanged; on case-insensitive filesystems, it converts the path to | 
 | 216 |    lowercase.  On Windows, it also converts forward slashes to backward slashes. | 
| Ezio Melotti | 5a3ef5b | 2010-06-25 10:56:11 +0000 | [diff] [blame] | 217 |    Raise a TypeError if the type of *path* is not ``str`` or ``bytes``. | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 218 |  | 
 | 219 |  | 
 | 220 | .. function:: normpath(path) | 
 | 221 |  | 
| Terry Jan Reedy | ec6e132 | 2013-03-17 15:21:26 -0400 | [diff] [blame] | 222 |    Normalize a pathname by collapsing redundant separators and up-level | 
 | 223 |    references so that ``A//B``, ``A/B/``, ``A/./B`` and ``A/foo/../B`` all | 
 | 224 |    become ``A/B``.  This string manipulation may change the meaning of a path | 
 | 225 |    that contains symbolic links.  On Windows, it converts forward slashes to | 
| Terry Jan Reedy | f346041 | 2013-03-17 15:28:10 -0400 | [diff] [blame] | 226 |    backward slashes. To normalize case, use :func:`normcase`. | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 227 |  | 
 | 228 |  | 
 | 229 | .. function:: realpath(path) | 
 | 230 |  | 
 | 231 |    Return the canonical path of the specified filename, eliminating any symbolic | 
 | 232 |    links encountered in the path (if they are supported by the operating system). | 
 | 233 |  | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 234 |  | 
| Georg Brandl | 1824415 | 2009-09-02 20:34:52 +0000 | [diff] [blame] | 235 | .. function:: relpath(path, start=None) | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 236 |  | 
| R David Murray | ce10fab | 2013-07-12 17:43:11 -0400 | [diff] [blame] | 237 |    Return a relative filepath to *path* either from the current directory or | 
 | 238 |    from an optional *start* directory.  This is a path computation:  the | 
 | 239 |    filesystem is not accessed to confirm the existence or nature of *path* or | 
 | 240 |    *start*. | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 241 |  | 
| Benjamin Peterson | f650e46 | 2010-05-06 23:03:05 +0000 | [diff] [blame] | 242 |    *start* defaults to :attr:`os.curdir`. | 
 | 243 |  | 
| Antoine Pitrou | f10f162 | 2010-12-12 20:17:29 +0000 | [diff] [blame] | 244 |    Availability: Unix, Windows. | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 245 |  | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 246 |  | 
 | 247 | .. function:: samefile(path1, path2) | 
 | 248 |  | 
| Brian Curtin | d40e6f7 | 2010-07-08 21:39:08 +0000 | [diff] [blame] | 249 |    Return ``True`` if both pathname arguments refer to the same file or directory. | 
 | 250 |    On Unix, this is determined by the device number and i-node number and raises an | 
 | 251 |    exception if a :func:`os.stat` call on either pathname fails. | 
| Benjamin Peterson | f650e46 | 2010-05-06 23:03:05 +0000 | [diff] [blame] | 252 |  | 
| Brian Curtin | d40e6f7 | 2010-07-08 21:39:08 +0000 | [diff] [blame] | 253 |    On Windows, two files are the same if they resolve to the same final path | 
| Brian Curtin | c739569 | 2010-07-09 15:15:09 +0000 | [diff] [blame] | 254 |    name using the Windows API call GetFinalPathNameByHandle. This function | 
| Brian Curtin | d40e6f7 | 2010-07-08 21:39:08 +0000 | [diff] [blame] | 255 |    raises an exception if handles cannot be obtained to either file. | 
 | 256 |  | 
| Antoine Pitrou | f10f162 | 2010-12-12 20:17:29 +0000 | [diff] [blame] | 257 |    Availability: Unix, Windows. | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 258 |  | 
| Georg Brandl | b382337 | 2010-07-10 08:58:37 +0000 | [diff] [blame] | 259 |    .. versionchanged:: 3.2 | 
 | 260 |       Added Windows support. | 
| Brian Curtin | c739569 | 2010-07-09 15:15:09 +0000 | [diff] [blame] | 261 |  | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 262 |  | 
 | 263 | .. function:: sameopenfile(fp1, fp2) | 
 | 264 |  | 
 | 265 |    Return ``True`` if the file descriptors *fp1* and *fp2* refer to the same file. | 
| Benjamin Peterson | f650e46 | 2010-05-06 23:03:05 +0000 | [diff] [blame] | 266 |  | 
| Brian Curtin | 6285774 | 2010-09-06 17:07:27 +0000 | [diff] [blame] | 267 |    Availability: Unix, Windows. | 
 | 268 |  | 
| Georg Brandl | 61063cc | 2012-06-24 22:48:30 +0200 | [diff] [blame] | 269 |    .. versionchanged:: 3.2 | 
 | 270 |       Added Windows support. | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 271 |  | 
 | 272 |  | 
 | 273 | .. function:: samestat(stat1, stat2) | 
 | 274 |  | 
 | 275 |    Return ``True`` if the stat tuples *stat1* and *stat2* refer to the same file. | 
 | 276 |    These structures may have been returned by :func:`fstat`, :func:`lstat`, or | 
 | 277 |    :func:`stat`.  This function implements the underlying comparison used by | 
| Benjamin Peterson | f650e46 | 2010-05-06 23:03:05 +0000 | [diff] [blame] | 278 |    :func:`samefile` and :func:`sameopenfile`. | 
 | 279 |  | 
 | 280 |    Availability: Unix. | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 281 |  | 
 | 282 |  | 
 | 283 | .. function:: split(path) | 
 | 284 |  | 
| Georg Brandl | 539c165 | 2010-10-14 06:46:08 +0000 | [diff] [blame] | 285 |    Split the pathname *path* into a pair, ``(head, tail)`` where *tail* is the | 
 | 286 |    last pathname component and *head* is everything leading up to that.  The | 
 | 287 |    *tail* part will never contain a slash; if *path* ends in a slash, *tail* | 
 | 288 |    will be empty.  If there is no slash in *path*, *head* will be empty.  If | 
 | 289 |    *path* is empty, both *head* and *tail* are empty.  Trailing slashes are | 
 | 290 |    stripped from *head* unless it is the root (one or more slashes only).  In | 
 | 291 |    all cases, ``join(head, tail)`` returns a path to the same location as *path* | 
| Chris Jerdonek | 0b502ff | 2012-11-25 20:38:01 -0800 | [diff] [blame] | 292 |    (but the strings may differ).  Also see the functions :func:`dirname` and | 
 | 293 |    :func:`basename`. | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 294 |  | 
 | 295 |  | 
 | 296 | .. function:: splitdrive(path) | 
 | 297 |  | 
 | 298 |    Split the pathname *path* into a pair ``(drive, tail)`` where *drive* is either | 
| Mark Hammond | 5a607a3 | 2009-05-06 08:04:54 +0000 | [diff] [blame] | 299 |    a mount point or the empty string.  On systems which do not use drive | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 300 |    specifications, *drive* will always be the empty string.  In all cases, ``drive | 
 | 301 |    + tail`` will be the same as *path*. | 
 | 302 |  | 
| Mark Hammond | 5a607a3 | 2009-05-06 08:04:54 +0000 | [diff] [blame] | 303 |    On Windows, splits a pathname into drive/UNC sharepoint and relative path. | 
 | 304 |  | 
 | 305 |    If the path contains a drive letter, drive will contain everything | 
 | 306 |    up to and including the colon. | 
 | 307 |    e.g. ``splitdrive("c:/dir")`` returns ``("c:", "/dir")`` | 
 | 308 |  | 
 | 309 |    If the path contains a UNC path, drive will contain the host name | 
 | 310 |    and share, up to but not including the fourth separator. | 
 | 311 |    e.g. ``splitdrive("//host/computer/dir")`` returns ``("//host/computer", "/dir")`` | 
 | 312 |  | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 313 |  | 
 | 314 | .. function:: splitext(path) | 
 | 315 |  | 
 | 316 |    Split the pathname *path* into a pair ``(root, ext)``  such that ``root + ext == | 
 | 317 |    path``, and *ext* is empty or begins with a period and contains at most one | 
 | 318 |    period. Leading periods on the basename are  ignored; ``splitext('.cshrc')`` | 
 | 319 |    returns  ``('.cshrc', '')``. | 
 | 320 |  | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 321 |  | 
 | 322 | .. function:: splitunc(path) | 
 | 323 |  | 
| Mark Hammond | 5a607a3 | 2009-05-06 08:04:54 +0000 | [diff] [blame] | 324 |    .. deprecated:: 3.1 | 
 | 325 |       Use *splitdrive* instead. | 
 | 326 |  | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 327 |    Split the pathname *path* into a pair ``(unc, rest)`` so that *unc* is the UNC | 
 | 328 |    mount point (such as ``r'\\host\mount'``), if present, and *rest* the rest of | 
 | 329 |    the path (such as  ``r'\path\file.ext'``).  For paths containing drive letters, | 
| Benjamin Peterson | f650e46 | 2010-05-06 23:03:05 +0000 | [diff] [blame] | 330 |    *unc* will always be the empty string. | 
 | 331 |  | 
 | 332 |    Availability:  Windows. | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 333 |  | 
 | 334 |  | 
| Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 335 | .. data:: supports_unicode_filenames | 
 | 336 |  | 
 | 337 |    True if arbitrary Unicode strings can be used as file names (within limitations | 
| Victor Stinner | b55e498 | 2010-09-11 00:22:12 +0000 | [diff] [blame] | 338 |    imposed by the file system). |