Changeset 391 for python/trunk/Doc/library/os.path.rst
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Doc/library/os.path.rst
r2 r391 16 16 :func:`splitunc` and :func:`ismount` do handle them correctly. 17 17 18 19 Unlike a unix shell, Python does not do any *automatic* path expansions. 20 Functions such as :func:`expanduser` and :func:`expandvars` can be invoked 21 explicitly when an application desires shell-like path expansion. (See also 22 the :mod:`glob` module.) 18 23 19 24 .. note:: … … 36 41 37 42 Return a normalized absolutized version of the pathname *path*. On most 38 platforms, this is equivalent to ``normpath(join(os.getcwd(), path))``. 43 platforms, this is equivalent to calling the function :func:`normpath` as 44 follows: ``normpath(join(os.getcwd(), path))``. 39 45 40 46 .. versionadded:: 1.5.2 … … 43 49 .. function:: basename(path) 44 50 45 Return the base name of pathname *path*. This is the second half of the pair 46 returned by ``split(path)``. Note that the result of this function is different 51 Return the base name of pathname *path*. This is the second element of the 52 pair returned by passing *path* to the function :func:`split`. Note that 53 the result of this function is different 47 54 from the Unix :program:`basename` program; where :program:`basename` for 48 55 ``'/foo/bar/'`` returns ``'bar'``, the :func:`basename` function returns an … … 59 66 .. function:: dirname(path) 60 67 61 Return the directory name of pathname *path*. This is the first half of the62 pair returned by ``split(path)``.68 Return the directory name of pathname *path*. This is the first element of 69 the pair returned by passing *path* to the function :func:`split`. 63 70 64 71 … … 141 148 142 149 Return the system's ctime which, on some systems (like Unix) is the time of the 143 last change, and, on others (like Windows), is the creation time for *path*.150 last metadata change, and, on others (like Windows), is the creation time for *path*. 144 151 The return value is a number giving the number of seconds since the epoch (see 145 152 the :mod:`time` module). Raise :exc:`os.error` if the file does not exist or … … 197 204 if there was one) are thrown away, and joining continues. The return value is 198 205 the concatenation of *path1*, and optionally *path2*, etc., with exactly one 199 directory separator (``os.sep``) inserted between components, unless *path2* is 200 empty. Note that on Windows, since there is a current directory for each drive, 201 ``os.path.join("c:", "foo")`` represents a path relative to the current 202 directory on drive :file:`C:` (:file:`c:foo`), not :file:`c:\\foo`. 206 directory separator (``os.sep``) following each non-empty part except the last. 207 (This means that an empty last part will result in a path that ends with a 208 separator.) Note that on Windows, since there is a current directory for 209 each drive, ``os.path.join("c:", "foo")`` represents a path relative to the 210 current directory on drive :file:`C:` (:file:`c:foo`), not :file:`c:\\foo`. 203 211 204 212 … … 212 220 .. function:: normpath(path) 213 221 214 Normalize a pathname . This collapsesredundant separators and up-level215 references so that ``A//B``, ``A/ ./B`` and ``A/foo/../B`` all become ``A/B``.216 It does not normalize the case (use :func:`normcase` for that). On Windows, it217 converts forward slashes to backward slashes. It should be understood that this218 may change the meaning of the path if it contains symbolic links!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 226 backward slashes. To normalize case, use :func:`normcase`. 219 227 220 228 … … 229 237 .. function:: relpath(path[, start]) 230 238 231 Return a relative filepath to *path* either from the current directory or from 232 an optional *start* point. 233 234 *start* defaults to :attr:`os.curdir`. Availability: Windows, Unix. 239 Return a relative filepath to *path* either from the current directory or 240 from an optional *start* directory. This is a path computation: the 241 filesystem is not accessed to confirm the existence or nature of *path* or 242 *start*. 243 244 *start* defaults to :attr:`os.curdir`. 245 246 Availability: Windows, Unix. 235 247 236 248 .. versionadded:: 2.6 … … 241 253 Return ``True`` if both pathname arguments refer to the same file or directory 242 254 (as indicated by device number and i-node number). Raise an exception if a 243 :func:`os.stat` call on either pathname fails. Availability: Unix. 255 :func:`os.stat` call on either pathname fails. 256 257 Availability: Unix. 244 258 245 259 … … 247 261 248 262 Return ``True`` if the file descriptors *fp1* and *fp2* refer to the same file. 263 249 264 Availability: Unix. 250 265 … … 253 268 254 269 Return ``True`` if the stat tuples *stat1* and *stat2* refer to the same file. 255 These structures may have been returned by :func:`fstat`, :func:`lstat`, or 256 :func:`stat`. This function implements the underlying comparison used by 257 :func:`samefile` and :func:`sameopenfile`. Availability: Unix. 270 These structures may have been returned by :func:`os.fstat`, 271 :func:`os.lstat`, or :func:`os.stat`. This function implements the 272 underlying comparison used by :func:`samefile` and :func:`sameopenfile`. 273 274 Availability: Unix. 258 275 259 276 260 277 .. function:: split(path) 261 278 262 Split the pathname *path* into a pair, ``(head, tail)`` where *tail* is the last 263 pathname component and *head* is everything leading up to that. The *tail* part 264 will never contain a slash; if *path* ends in a slash, *tail* will be empty. If 265 there is no slash in *path*, *head* will be empty. If *path* is empty, both 266 *head* and *tail* are empty. Trailing slashes are stripped from *head* unless 267 it is the root (one or more slashes only). In nearly all cases, ``join(head, 268 tail)`` equals *path* (the only exception being when there were multiple slashes 269 separating *head* from *tail*). 279 Split the pathname *path* into a pair, ``(head, tail)`` where *tail* is the 280 last pathname component and *head* is everything leading up to that. The 281 *tail* part will never contain a slash; if *path* ends in a slash, *tail* 282 will be empty. If there is no slash in *path*, *head* will be empty. If 283 *path* is empty, both *head* and *tail* are empty. Trailing slashes are 284 stripped from *head* unless it is the root (one or more slashes only). In 285 all cases, ``join(head, tail)`` returns a path to the same location as *path* 286 (but the strings may differ). Also see the functions :func:`dirname` and 287 :func:`basename`. 270 288 271 289 … … 297 315 mount point (such as ``r'\\host\mount'``), if present, and *rest* the rest of 298 316 the path (such as ``r'\path\file.ext'``). For paths containing drive letters, 299 *unc* will always be the empty string. Availability: Windows. 317 *unc* will always be the empty string. 318 319 Availability: Windows. 300 320 301 321 … … 320 340 .. note:: 321 341 322 This function is deprecated and has been removed in 3.0in favor of342 This function is deprecated and has been removed in Python 3 in favor of 323 343 :func:`os.walk`. 324 344 … … 327 347 328 348 True if arbitrary Unicode strings can be used as file names (within limitations 329 imposed by the file system), and if :func:`os.listdir` returns Unicode strings 330 for a Unicode argument. 349 imposed by the file system). 331 350 332 351 .. versionadded:: 2.3
Note:
See TracChangeset
for help on using the changeset viewer.