Skip to content

Commit 87076d8

Browse files
gh-100783: fix os.path.join documentation (GH-100811)
- Use "drive", not "drive letter", because of UNC paths - Previous components are not thrown away from relative drive letters - Use "segment" instead of "component" for consistency with pathlib - Other miscellaneous improvements (cherry picked from commit 53455a3) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
1 parent caed845 commit 87076d8

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

Doc/library/os.path.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -297,17 +297,18 @@ the :mod:`glob` module.)
297297

298298
.. function:: join(path, *paths)
299299

300-
Join one or more path components intelligently. The return value is the
301-
concatenation of *path* and any members of *\*paths* with exactly one
302-
directory separator following each non-empty part except the last, meaning
303-
that the result will only end in a separator if the last part is empty. If
304-
a component is an absolute path, all previous components are thrown away
305-
and joining continues from the absolute path component.
306-
307-
On Windows, the drive letter is not reset when an absolute path component
308-
(e.g., ``r'\foo'``) is encountered. If a component contains a drive
309-
letter, all previous components are thrown away and the drive letter is
310-
reset. Note that since there is a current directory for each drive,
300+
Join one or more path segments intelligently. The return value is the
301+
concatenation of *path* and all members of *\*paths*, with exactly one
302+
directory separator following each non-empty part except the last. That is,
303+
if the last part is empty, the result will end in a separator. If
304+
a segment is an absolute path (which on Windows requires both a drive and a
305+
root), then all previous segments are ignored and joining continues from the
306+
absolute path segment.
307+
308+
On Windows, the drive is not reset when a rooted path segment (e.g.,
309+
``r'\foo'``) is encountered. If a segment is on a different drive or is an
310+
absolute path, all previous segments are ignored and the drive is reset. Note
311+
that since there is a current directory for each drive,
311312
``os.path.join("c:", "foo")`` represents a path relative to the current
312313
directory on drive :file:`C:` (:file:`c:foo`), not :file:`c:\\foo`.
313314

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy