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-39534: Clarify return in finally #18324
Conversation
The new wording looks good. The only suggestion I would make is to remove the links from some of the keywords, like they are in the paragraph above this one. It may not be necessary to have every |
@csabella Removed a few links, good idea, too much blue don't help the readability (kept only one link per keyword on the whole list). |
If a finally clause includes a return statement, then always the expression after the return in finally will be returned. However, if try or except also has a return statement, in such a case the expression after that return statement will be evaluated but not returned. Also, the expression in try is always evaluated before the expression in finally.
I think this is how someone new to python can understand what will exactly happen in this case. @JulienPalard.
Looks a bit too heavy for me, we're in a tutorial, not in |
I agree with Julien. After reading this section of the tutorial, I think it's good that the bullet points highlight how the try/except/finally work together at a high level so that the reader can understand the general behavior, but I don't think it's necessary to go into it in more detail. Once the reader moves beyond the tutorial into the other docs, they will gain any deeper level of understanding when they need it. |
Thanks @JulienPalard for the PR |
I'm having trouble backporting to |
(cherry picked from commit 446463f) Co-authored-by: Julien Palard <julien@palard.fr>
GH-18386 is a backport of this pull request to the 3.7 branch. |
Thanks @JulienPalard for the PR |
Thanks @JulienPalard for the PR |
(cherry picked from commit 446463f) Co-authored-by: Julien Palard <julien@palard.fr>
GH-18387 is a backport of this pull request to the 3.8 branch. |
bpo-39534: Doc: Clarify return in finally (pythonGH-18324)
I rewrapped the lines around my edit in another commit, to see just my wording change, select the first commit only.
https://bugs.python.org/issue39534