Skip to content

Commit a978c6c

Browse files
authored
Update os.path.rst
1 parent 0ef4ffe commit a978c6c

File tree

1 file changed

+31
-11
lines changed

1 file changed

+31
-11
lines changed

Doc/library/os.path.rst

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

5656

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

@@ -238,14 +241,16 @@ the :mod:`glob` module.)
238241

239242

240243
.. function:: isabs(path)
241-
242244
Return ``True`` if *path* is an absolute pathname. On Unix, that means it
243245
begins with a slash, on Windows that it begins with two (back)slashes, or a
244246
drive letter, colon, and (back)slash together.
245-
247+
248+
.. seealso::
249+
:func:`abspath` - Returns the absolute version of a path
250+
246251
.. versionchanged:: 3.6
247252
Accepts a :term:`path-like object`.
248-
253+
249254
.. versionchanged:: 3.13
250255
On Windows, returns ``False`` if the given path starts with exactly one
251256
(back)slash.
@@ -351,22 +356,32 @@ the :mod:`glob` module.)
351356

352357

353358
.. function:: join(path, *paths)
354-
359+
355360
Join one or more path segments intelligently. The return value is the
356361
concatenation of *path* and all members of *\*paths*, with exactly one
357362
directory separator following each non-empty part, except the last. That is,
358363
the result will only end in a separator if the last part is either empty or
359364
ends in a separator. If a segment is an absolute path (which on Windows
360365
requires both a drive and a root), then all previous segments are ignored and
361366
joining continues from the absolute path segment.
362-
367+
368+
Examples::
369+
370+
>>> os.path.join('/home/foo', 'bar')
371+
'/home/foo/bar'
372+
>>> os.path.join('/home/foo', '/home/bar')
373+
'/home/bar'
374+
375+
The second example demonstrates how an absolute path argument ignores all
376+
previous path segments.
377+
363378
On Windows, the drive is not reset when a rooted path segment (e.g.,
364379
``r'\foo'``) is encountered. If a segment is on a different drive or is an
365380
absolute path, all previous segments are ignored and the drive is reset. Note
366381
that since there is a current directory for each drive,
367382
``os.path.join("c:", "foo")`` represents a path relative to the current
368383
directory on drive :file:`C:` (:file:`c:foo`), not :file:`c:\\foo`.
369-
384+
370385
.. versionchanged:: 3.6
371386
Accepts a :term:`path-like object` for *path* and *paths*.
372387

@@ -486,7 +501,7 @@ the :mod:`glob` module.)
486501

487502

488503
.. function:: split(path)
489-
504+
490505
Split the pathname *path* into a pair, ``(head, tail)`` where *tail* is the
491506
last pathname component and *head* is everything leading up to that. The
492507
*tail* part will never contain a slash; if *path* ends in a slash, *tail*
@@ -496,9 +511,14 @@ the :mod:`glob` module.)
496511
all cases, ``join(head, tail)`` returns a path to the same location as *path*
497512
(but the strings may differ). Also see the functions :func:`dirname` and
498513
:func:`basename`.
499-
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+
500520
.. versionchanged:: 3.6
501-
Accepts a :term:`path-like object`.
521+
Accepts a :term:`path-like object`..
502522

503523

504524
.. function:: splitdrive(path)

0 commit comments

Comments
 (0)