Uh oh!
There was an error while loading. Please reload this page.
gh-87691: clarify use of anchor in pathlib docs - #100782
Conversation
This is feedback from python#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". While matching wording, I noticed that the constructor section uses the word "segment". This word does not appear elsewhere in the docs or code; we already have "part" and "component" to refer to the same concept in the pathlib context.
JelleZijlstra
left a comment
There was a problem hiding this comment.
Looks good with some small nits; feel free to merge if @barneygale is on board.
Uh oh!
There was an error while loading. Please reload this page.
| However, in a Windows path, changing the local root doesn't discard the | ||
| previous drive setting:: | ||
| On Windows, the drive letter is not reset when a drive-less absolute path |
There was a problem hiding this comment.
Is the drive necessarily one letter?
There was a problem hiding this comment.
Good question, I think the drive can be a UNC path. This also would need to get fixed in the os.path.join documentation: https://docs.python.org/3/library/os.path.html#os.path.join
>>> PureWindowsPath("hello", "//host/computer/dir", "/asdf")
PureWindowsPath('//host/computer/asdf')
>>> ntpath.join("hello", "//host/computer/dir", "/asdf")
'//host/computer/asdf'I'll update to "drive" and open a second PR for os.path.join if @barneygale concurs
There was a problem hiding this comment.
"drive" makes more sense to me too.
Uh oh!
There was an error while loading. Please reload this page.
barneygale
commented
Jan 6, 2023
They're not quite the same! A "part" is a component in a fully-normalized path. Unless it's an anchor, a part can't contain any path separators. Contrast this with a "segment" which can contain separators and might even be a fully-fledged path in its own right! |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
re segment: Ah, makes sense, I knew I had to be missing something I filed #100783 for some issues in |
Co-authored-by: Barney Gale <barney.gale@gmail.com>
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Barney Gale <barney.gale@gmail.com>
miss-islington
commented
Jan 6, 2023
Thanks @hauntsaninja for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11. |
bedevere-bot
commented
Jan 6, 2023
GH-100786 is a backport of this pull request to the 3.11 branch. |
bedevere-bot
commented
Jan 6, 2023
GH-100787 is a backport of this pull request to the 3.10 branch. |
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 2f2fa03) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Co-authored-by: Barney Gale <barney.gale@gmail.com>
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 2f2fa03) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Co-authored-by: Barney Gale <barney.gale@gmail.com>
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 2f2fa03) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Co-authored-by: Barney Gale <barney.gale@gmail.com>
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 2f2fa03) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Co-authored-by: Barney Gale <barney.gale@gmail.com>
AlexWaygood
commented
Jan 6, 2023
@barneygale, fancy adding yourself to CODEOWNERS so you get automatically requested for review on PRs touching |
AlexWaygood
commented
Jan 6, 2023
You could also consider adding yourself to https://devguide.python.org/core-developers/experts/index.html#experts as a pathlib expert — there's already at least one triager on the experts list :-) |
This is feedback from #100737 (comment)
This matches the wording from the
os.path.joindocs better: https://docs.python.org/3/library/os.path.html#os.path.joinIn particular, the previous use of "anchor" was incorrect given the pathlib definition of "anchor".
Co-authored-by: barneygale