summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-01-06 01:56:34 (GMT)
committerGitHub <noreply@github.com>2023-01-06 01:56:34 (GMT)
commitf5fa2c1e7f158fbc2ac4ad936e39fbe6253ae354 (patch)
tree7db0747071548004cc9d2e43e2389f4eb3b3e47e /Doc
parent4bdc57a3d2aceadbc9150febe6717ef92b8d6aa5 (diff)
downloadcpython-f5fa2c1e7f158fbc2ac4ad936e39fbe6253ae354.zip
cpython-f5fa2c1e7f158fbc2ac4ad936e39fbe6253ae354.tar.gz
cpython-f5fa2c1e7f158fbc2ac4ad936e39fbe6253ae354.tar.bz2
gh-87691: clarify use of anchor in pathlib docs (GH-100782)
This is feedback from https://github.com/python/cpython/pull/100737GH-discussion_r1062968696 This matches the wording from the `os.path.join` docs better: https://docs.python.org/3/library/os.path.htmlGH-os.path.join In particular, the previous use of "anchor" was incorrect given the pathlib definition of "anchor". (cherry picked from commit 2f2fa03ff3d566b675020787e23de8fb4ca78e99) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Co-authored-by: Barney Gale <barney.gale@gmail.com>
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/pathlib.rst16
1 files changed, 8 insertions, 8 deletions
diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst
index 316fee2..881f8d6 100644
--- a/Doc/library/pathlib.rst
+++ b/Doc/library/pathlib.rst
@@ -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`)::
>>> 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')
@@ -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