Skip to content

Commit 231335f

Browse files
authored
Adjusted os.path.rst details
1 parent a978c6c commit 231335f

File tree

1 file changed

+32
-36
lines changed

1 file changed

+32
-36
lines changed

Doc/library/os.path.rst

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,12 @@ the :mod:`glob` module.)
5555

5656

5757
.. function:: abspath(path)
58+
5859
Return a normalized absolutized version of the pathname *path*. On most
59-
platforms, this is equivalent to calling the function :func:`normpath` as
60-
follows: ``normpath(join(os.getcwd(), path))``.
61-
62-
.. seealso::
63-
:func:`join` - Used by abspath to combine paths
64-
:func:`normpath` - Used by abspath to normalize paths
65-
60+
platforms, this is equivalent to calling ``normpath(join(os.getcwd(), path))``.
61+
62+
.. seealso:: :func:`os.path.join` and :func:`os.path.normpath`.
63+
6664
.. versionchanged:: 3.6
6765
Accepts a :term:`path-like object`.
6866

@@ -241,16 +239,15 @@ the :mod:`glob` module.)
241239

242240

243241
.. function:: isabs(path)
242+
244243
Return ``True`` if *path* is an absolute pathname. On Unix, that means it
245244
begins with a slash, on Windows that it begins with two (back)slashes, or a
246245
drive letter, colon, and (back)slash together.
247-
248-
.. seealso::
249-
:func:`abspath` - Returns the absolute version of a path
250-
246+
247+
.. seealso:: :func:`abspath`
248+
251249
.. versionchanged:: 3.6
252250
Accepts a :term:`path-like object`.
253-
254251
.. versionchanged:: 3.13
255252
On Windows, returns ``False`` if the given path starts with exactly one
256253
(back)slash.
@@ -356,32 +353,36 @@ the :mod:`glob` module.)
356353

357354

358355
.. function:: join(path, *paths)
359-
356+
360357
Join one or more path segments intelligently. The return value is the
361358
concatenation of *path* and all members of *\*paths*, with exactly one
362359
directory separator following each non-empty part, except the last. That is,
363360
the result will only end in a separator if the last part is either empty or
364-
ends in a separator. If a segment is an absolute path (which on Windows
365-
requires both a drive and a root), then all previous segments are ignored and
366-
joining continues from the absolute path segment.
367-
368-
Examples::
369-
361+
ends in a separator.
362+
363+
If a segment is an absolute path (which on Windows requires both a drive and
364+
a root), then all previous segments are ignored and joining continues from the
365+
absolute path segment. For instance::
366+
370367
>>> os.path.join('/home/foo', 'bar')
371368
'/home/foo/bar'
372369
>>> os.path.join('/home/foo', '/home/bar')
373370
'/home/bar'
374-
375-
The second example demonstrates how an absolute path argument ignores all
376-
previous path segments.
377-
371+
378372
On Windows, the drive is not reset when a rooted path segment (e.g.,
379373
``r'\foo'``) is encountered. If a segment is on a different drive or is an
380-
absolute path, all previous segments are ignored and the drive is reset. Note
381-
that since there is a current directory for each drive,
374+
absolute path, all previous segments are ignored and the drive is reset. For
375+
instance::
376+
377+
>>> os.path.join('c:\\', 'foo')
378+
'c:\\foo'
379+
>>> os.path.join('c:\\foo', 'd:\\bar')
380+
'd:\\bar'
381+
382+
Note that since there is a current directory for each drive,
382383
``os.path.join("c:", "foo")`` represents a path relative to the current
383384
directory on drive :file:`C:` (:file:`c:foo`), not :file:`c:\\foo`.
384-
385+
385386
.. versionchanged:: 3.6
386387
Accepts a :term:`path-like object` for *path* and *paths*.
387388

@@ -501,24 +502,19 @@ the :mod:`glob` module.)
501502

502503

503504
.. function:: split(path)
504-
505+
505506
Split the pathname *path* into a pair, ``(head, tail)`` where *tail* is the
506507
last pathname component and *head* is everything leading up to that. The
507508
*tail* part will never contain a slash; if *path* ends in a slash, *tail*
508509
will be empty. If there is no slash in *path*, *head* will be empty. If
509510
*path* is empty, both *head* and *tail* are empty. Trailing slashes are
510511
stripped from *head* unless it is the root (one or more slashes only). In
511512
all cases, ``join(head, tail)`` returns a path to the same location as *path*
512-
(but the strings may differ). Also see the functions :func:`dirname` and
513-
:func:`basename`.
514-
515-
.. seealso::
516-
:func:`join` - Can be used to reconstruct a path from split components
517-
:func:`dirname` - Returns the directory name of a path
518-
:func:`basename` - Returns the base name of a path
519-
513+
(but the strings may differ). Also see the functions :func:`join`,
514+
:func:`dirname` and :func:`basename`.
515+
520516
.. versionchanged:: 3.6
521-
Accepts a :term:`path-like object`..
517+
Accepts a :term:`path-like object`.
522518

523519

524520
.. function:: splitdrive(path)

0 commit comments

Comments
 (0)