Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 24eb4bc

Browse files
committed
#9921: clarify os.path.join joining algorithm
The new wording is based on the comments in the code, which match the actual behavior.
1 parent 66f7d66 commit 24eb4bc

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

Doc/library/os.path.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,11 @@ applications should use string objects to access all files.
190190
path, all previous components (on Windows, including the previous drive letter,
191191
if there was one) are thrown away, and joining continues. The return value is
192192
the concatenation of *path1*, and optionally *path2*, etc., with exactly one
193-
directory separator (``os.sep``) inserted between components, unless *path2* is
194-
empty. Note that on Windows, since there is a current directory for each drive,
195-
``os.path.join("c:", "foo")`` represents a path relative to the current
196-
directory on drive :file:`C:` (:file:`c:foo`), not :file:`c:\\foo`.
193+
directory separator (``os.sep``) following each non-empty part except the last.
194+
(This means that an empty last part will result in a path that ends with a
195+
separator.) Note that on Windows, since there is a current directory for
196+
each drive, ``os.path.join("c:", "foo")`` represents a path relative to the
197+
current directory on drive :file:`C:` (:file:`c:foo`), not :file:`c:\\foo`.
197198

198199

199200
.. function:: normcase(path)

0 commit comments

Comments
 (0)