8000 gh-87691: clarify use of anchor in pathlib docs (#100782) · python/cpython@2f2fa03 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2f2fa03

Browse files
gh-87691: clarify use of anchor in pathlib docs (#100782)
This is feedback from #100737 (comment) This matches the wording from the `os.path.join` docs better: https://docs.python.org/3/library/os.path.html#os.path.join In particular, the previous use of "anchor" was incorrect given the pathlib definition of "anchor". Co-authored-by: Barney Gale <barney.gale@gmail.com>
1 parent 0a7936a commit 2f2fa03

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Doc/library/pathlib.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,16 @@ we also call *flavours*:
118118
>>> PurePath()
119119
PurePosixPath('.')
120120

121-
When several absolute paths are given, the last is taken as an anchor
122-
(mimicking :func:`os.path.join`'s behaviour)::
121+
If a segment is an absolute path, all previous segments are ignored
122+
(like :func:`os.path.join`)::
123123

124124
>>> PurePath('/etc', '/usr', 'lib64')
125125
PurePosixPath('/usr/lib64')
126126
>>> PureWindowsPath('c:/Windows', 'd:bar')
127127
PureWindowsPath('d:bar')
128128

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

132132
>>> PureWindowsPath('c:/Windows', '/Program Files')
133133
PureWindowsPath('c:/Program Files')
@@ -212,10 +212,10 @@ Paths of a different flavour compare unequal and cannot be ordered::
212212
Operators
213213
^^^^^^^^^
214214

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

220220
>>> p = PurePath('/etc')
221221
>>> p

0 commit comments

Comments
 (0)
0