-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-130536: Added details to os.path
documentation
#130557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
arthurlw
wants to merge
3
commits into
python:main
Choose a base branch
from
arthurlw:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,8 +57,9 @@ the :mod:`glob` module.) | |
.. function:: abspath(path) | ||
|
||
Return a normalized absolutized version of the pathname *path*. On most | ||
platforms, this is equivalent to calling the function :func:`normpath` as | ||
follows: ``normpath(join(os.getcwd(), path))``. | ||
platforms, this is equivalent to calling ``normpath(join(os.getcwd(), path))``. | ||
|
||
.. seealso:: :func:`os.path.join` and :func:`os.path.normpath`. | ||
|
||
.. versionchanged:: 3.6 | ||
Accepts a :term:`path-like object`. | ||
|
@@ -243,6 +244,8 @@ the :mod:`glob` module.) | |
begins with a slash, on Windows that it begins with two (back)slashes, or a | ||
drive letter, colon, and (back)slash together. | ||
|
||
.. seealso:: :func:`abspath` | ||
|
||
.. versionchanged:: 3.6 | ||
Accepts a :term:`path-like object`. | ||
|
||
|
@@ -356,14 +359,28 @@ the :mod:`glob` module.) | |
concatenation of *path* and all members of *\*paths*, with exactly one | ||
directory separator following each non-empty part, except the last. That is, | ||
the result will only end in a separator if the last part is either empty or | ||
ends in a separator. If a segment is an absolute path (which on Windows | ||
requires both a drive and a root), then all previous segments are ignored and | ||
joining continues from the absolute path segment. | ||
ends in a separator. | ||
|
||
If a segment is an absolute path (which on Windows requires both a drive and | ||
a root), then all previous segments are ignored and joining continues from the | ||
absolute path segment. For example:: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to confirm, this example is non-Windows only right? namely macOS and Linux right? If so, I would add "On Linux, for example::" (the paragraph is not exactly Linux specific but the example is) |
||
|
||
>>> os.path.join('/home/foo', 'bar') | ||
'/home/foo/bar' | ||
>>> os.path.join('/home/foo', '/home/bar') | ||
'/home/bar' | ||
|
||
On Windows, the drive is not reset when a rooted path segment (e.g., | ||
``r'\foo'``) is encountered. If a segment is on a different drive or is an | ||
absolute path, all previous segments are ignored and the drive is reset. Note | ||
that since there is a current directory for each drive, | ||
absolute path, all previous segments are ignored and the drive is reset. For | ||
example:: | ||
|
||
>>> os.path.join('c:\\', 'foo') | ||
'c:\\foo' | ||
>>> os.path.join('c:\\foo', 'd:\\bar') | ||
'd:\\bar' | ||
|
||
Note that since there is a current directory for each drive, | ||
``os.path.join("c:", "foo")`` represents a path relative to the current | ||
directory on drive :file:`C:` (:file:`c:foo`), not :file:`c:\\foo`. | ||
|
||
|
@@ -494,8 +511,8 @@ the :mod:`glob` module.) | |
*path* is empty, both *head* and *tail* are empty. Trailing slashes are | ||
stripped from *head* unless it is the root (one or more slashes only). In | ||
all cases, ``join(head, tail)`` returns a path to the same location as *path* | ||
(but the strings may differ). Also see the functions :func:`dirname` and | ||
:func:`basename`. | ||
(but the strings may differ). Also see the functions :func:`join`, | ||
:func:`dirname` and :func:`basename`. | ||
|
||
.. versionchanged:: 3.6 | ||
Accepts a :term:`path-like object`. | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.