-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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: 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
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. |
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" |
That's about the Path constructor, not the slash operator. I don't think it's obvious to users that these behave the same. |
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:
|
That sounds good to me. |
Status check is done, and it's a success ✅. |
Thanks @hauntsaninja for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11. |
GH-100780 is a backport of this pull request to the 3.11 branch. |
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
@barneygale sorry this got merged without your review, I forgot about the automerge label when I approved. |
D'oh, I should have noticed. My feedback is just nits, the patch that went in looks fine. |
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