Skip to content
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

bpo-38558: Link to further docs from walrus operator mention in tutorial #16973

Merged
merged 11 commits into from
Feb 3, 2020

Conversation

adorilson
Copy link
Contributor

@adorilson adorilson commented Oct 28, 2019

This PR:

  1. add versionchanged mark in walrus operation citation (to make explicited that this just works in 3.8 or later)
  2. remove mentions to C language (we can't assume that everybody knows what is C)
  3. add walrus operator example (example is always good)

https://bugs.python.org/issue38558

@ammaraskar
Copy link
Member

add versionchanged mark in walrus operation citation (to make explicited that this just works in 3.8 or later)

I don't think an off-hand mention in the tutorial is a good spot for versionchanged, those usually go in the actual methods/declarations that were changed. In this case I think the whatsnew entry that mentions the walrus operator adequately covers when it was added.

remove mentions to C language (we can't assume that everybody knows what is C)

You don't have to know what C is to broadly understand the problem here, one can just ignore the parts mentioning C and still understand it. I think the comparison to a known language where this bug is common helps clarify the motivation for the existence of the walrus.

add walrus operator example (example is always good)

An example would be useful but I think some thought needs to be given to what would be useful in this context and not covered by the walrus operator's whatsnew entry (maybe a link to it should be added instead).

@zware
Copy link
Member

zware commented Oct 29, 2019

Agreed with everything @ammaraskar mentioned. If anything is to be changed here, I think just a link to the docs for the walrus operator would be plenty.

@csabella
Copy link
Contributor

@adorilson, please respond to the review comments.

@adorilson
Copy link
Contributor Author

Hi, people.

I concord with some points, but not totally.

I'm OK about versionchanged, it was never used in tutorial. On the other hands, reference to whatsnew was not too (at least I don't found it). So in this point, is more consisted we link to PEP 572.

I think we need put some details about walrus operator in tutorial or at least a reference before datastructures chapter.

What's you think about first-steps-towards-programming section? It's look a good place for me. This section cite all the other operators used in conditions.

@JulienPalard
Copy link
Member

I concur with @zware, please keep it simple, it's just a note, and it's just a tutorial.

Just link to https://docs.python.org/3/faq/design.html#why-can-t-i-use-an-assignment-in-an-expression which is the only part of the doc where we "document" the walrus (there's /reference/ but again it's a tutorial, it's not nice to send newcomers to read the reference).

@csabella
Copy link
Contributor

@adorilson, I agree with @zware and @JulienPalard, where just adding a link would be best. The C language was mentioned in the prior version of this section. The change that added := here was just correcting a statement that was now untrue in that original note. Also, the intro to the tutorial says

This tutorial does not attempt to be comprehensive and cover every single feature, or even every commonly used feature. Instead, it introduces many of Python’s most noteworthy features, and will give you a good idea of the language’s flavor and style.

Based on that, I don't think it needs to be covered in detail. I checked the PEP for the discussions that had occurred around teaching this operator and didn't find anything there, but I seemed to recall that this operator was a more advanced concept that wouldn't need to be taught to beginners. I think it's OK to leave it out of the tutorial (except for correcting the original note), except, as others have suggested, adding a link to the note that was already added.

Thanks!

@adorilson
Copy link
Contributor Author

Just link to https://docs.python.org/3/faq/design.html#why-can-t-i-use-an-assignment-in-an-expression

I reverted the previous commits and I done this.

@zware zware added the needs backport to 3.8 only security fixes label Jan 19, 2020
@zware zware changed the title [Doc] Improvements about walrus operator in tutorial/datastructures bpo-38558: Link to further docs from walrus operator mention in tutorial Jan 19, 2020
Co-Authored-By: Cheryl Sabella <cheryl.sabella@gmail.com>
zware
zware previously requested changes Jan 20, 2020
Doc/tutorial/datastructures.rst Outdated Show resolved Hide resolved
Doc/tutorial/datastructures.rst Outdated Show resolved Hide resolved
@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

And if you don't make the requested changes, you will be put in the comfy chair!

@adorilson
Copy link
Contributor Author

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@zware: please review the changes made to this pull request.

@JulienPalard JulienPalard dismissed zware’s stale review February 3, 2020 17:10

Changes correctly applied.

@JulienPalard JulienPalard merged commit 5807efd into python:master Feb 3, 2020
@miss-islington
Copy link
Contributor

Thanks @adorilson for the PR, and @JulienPalard for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 3, 2020
…ial (pythonGH-16973)

(cherry picked from commit 5807efd)

Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
@bedevere-bot bedevere-bot removed the needs backport to 3.8 only security fixes label Feb 3, 2020
@bedevere-bot
Copy link

GH-18335 is a backport of this pull request to the 3.8 branch.

@JulienPalard
Copy link
Member

Thanks @adorilson for this PR!

miss-islington added a commit that referenced this pull request Feb 3, 2020
…ial (GH-16973)

(cherry picked from commit 5807efd)

Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
@adorilson adorilson deleted the explain_walrus branch March 25, 2024 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants