Skip to content
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

gh-87691: clarify use of anchor in pathlib docs #100782

Merged
merged 7 commits into from
Jan 6, 2023
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Doc/library/pathlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,16 @@ we also call *flavours*:
>>> PurePath()
PurePosixPath('.')

When several absolute paths are given, the last is taken as an anchor
(mimicking :func:`os.path.join`'s behaviour)::
If a segment is an absolute path, all previous segments are ignored
(like :func:`os.path.join`')::
hauntsaninja marked this conversation as resolved.
Show resolved Hide resolved

>>> PurePath('/etc', '/usr', 'lib64')
PurePosixPath('/usr/lib64')
>>> PureWindowsPath('c:/Windows', 'd:bar')
PureWindowsPath('d:bar')

However, in a Windows path, changing the local root doesn't discard the
previous drive setting::
On Windows, the drive is not reset when a rooted relative path
segment (e.g., ``r'\foo'``) is encountered::

>>> PureWindowsPath('c:/Windows', '/Program Files')
PureWindowsPath('c:/Program Files')
Expand Down Expand Up @@ -212,10 +212,10 @@ Paths of a different flavour compare unequal and cannot be ordered::
Operators
^^^^^^^^^

The slash operator helps create child paths, mimicking the behaviour of
:func:`os.path.join`. For instance, when several absolute paths are given, the
last is taken as an anchor; for a Windows path, changing the local root doesn't
discard the previous drive setting::
The slash operator helps create child paths, like :func:`os.path.join`.
If the argument is an absolute path, the previous path is ignored.
On Windows, the drive is not reset when the argument is a rooted
relative path (e.g., ``r'\foo'``)::

>>> p = PurePath('/etc')
>>> p
Expand Down