Uh oh!
There was an error while loading. Please reload this page.
gh-87691: add an absolute path pathlib example in / operator docs - #100737
Conversation
The behaviour is fully explained a couple paragraphs above, but it may be useful to have a brief example to cover the behaviour.
This is meant as a replacement for #24900. If we feel this is still unnecessary, we can just close out the issue. cc @barneygale |
Uh oh!
There was an error while loading. Please reload this page.
JelleZijlstra
commented
Jan 5, 2023
Where is this behavior explained? I don't see it in https://docs.python.org/3.10/library/pathlib.html#operators. I think a sentence spelling out the behavior might be useful. |
hauntsaninja
commented
Jan 5, 2023
It's explained in https://docs.python.org/3.10/library/pathlib.html#pathlib.PurePath , which is a couple paragraphs before Operators. Search for "When several absolute paths are given, the last is taken as an anchor" |
JelleZijlstra
commented
Jan 5, 2023
That's about the Path constructor, not the slash operator. I don't think it's obvious to users that these behave the same. |
hauntsaninja
commented
Jan 5, 2023
Hmm, what would you recommend? We could copy over just the text or the text and the examples. Also note the Windows drive example, which isn't covered by https://github.com/python/cpython/pull/24900/files Something like:
|
JelleZijlstra
commented
Jan 5, 2023
That sounds good to me. |
miss-islington
commented
Jan 5, 2023
Status check is done, and it's a success ✅. |
miss-islington
commented
Jan 5, 2023
Thanks @hauntsaninja for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11. |
bedevere-bot
commented
Jan 5, 2023
GH-100780 is a backport of this pull request to the 3.11 branch. |
bedevere-bot
commented
Jan 5, 2023
GH-100781 is a backport of this pull request to the 3.10 branch. |
…cs (pythonGH-100737) The behaviour is fully explained a couple paragraphs above, but it may be useful to have a brief example to cover the behaviour. (cherry picked from commit 1ae619c) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Automerge-Triggered-By: GH:hauntsaninja
…cs (pythonGH-100737) The behaviour is fully explained a couple paragraphs above, but it may be useful to have a brief example to cover the behaviour. (cherry picked from commit 1ae619c) Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Automerge-Triggered-By: GH:hauntsaninja
Uh oh!
There was an error while loading. Please reload this page.
JelleZijlstra
commented
Jan 5, 2023
@barneygale sorry this got merged without your review, I forgot about the automerge label when I approved. |
barneygale
commented
Jan 5, 2023
D'oh, I should have noticed. My feedback is just nits, the patch that went in looks fine. |
hauntsaninja
commented
Jan 5, 2023
Hmm, I think your point that "anchor" is defined differently in pathlib is more than just a nit. I'll open another PR, sigh And sorry for my part in the automerge situation! |
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.
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>
The behaviour is fully explained a couple paragraphs above, but it may be useful to have a brief example to cover the behaviour.
Automerge-Triggered-By: GH:hauntsaninja