-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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-126664: Use else
instead of finally
in "The with statement" documentation.
#126665
Conversation
…nt" documentation. (pythonGH-126665) (cherry picked from commit 25257d6) Co-authored-by: vivodi <[email protected]>
GH-126670 is a backport of this pull request to the 3.13 branch. |
…nt" documentation. (pythonGH-126665) (cherry picked from commit 25257d6) Co-authored-by: vivodi <[email protected]>
GH-126671 is a backport of this pull request to the 3.12 branch. |
…nt" documentation. (pythonGH-126665)
The But I think this should be reverted. The semantically-equivalent sample code is not helpful if it applies only to suites without those kinds of statements (or it would be confusing to qualify when the semantics are correct). Example: for _ in range(1):
try:
break
except:
pass
else:
print('exit') produces no output (as expected for a but this does (as expected for a class Context:
def __enter__(self):
pass
def __exit__(self, *args):
print('exit')
for _ in range(1):
with Context():
break |
… statement" documentation. (pythonGH-126665)" This reverts commit 25257d6.
thanks! yes, you are correct. revert PRs in flight. |
…aining "with" (pythonGH-128169) Revert "pythongh-126664: Use `else` instead of `finally` in "The with statement" documentation. (pythonGH-126665)" This reverts commit 25257d6. (cherry picked from commit 228f275) Co-authored-by: Gregory P. Smith <[email protected]>
…aining "with" (pythonGH-128169) Revert "pythongh-126664: Use `else` instead of `finally` in "The with statement" documentation. (pythonGH-126665)" This reverts commit 25257d6. (cherry picked from commit 228f275) Co-authored-by: Gregory P. Smith <[email protected]>
…aining "with" (python#128169) Revert "pythongh-126664: Use `else` instead of `finally` in "The with statement" documentation. (pythonGH-126665)" This reverts commit 25257d6.
Documentation
In 8.5 The
with
statement, we can useelse
instead offinally
.is semantically equivalent to:
else
instead offinally
in "The with statement" documentation. #126664📚 Documentation preview 📚: https://cpython-previews--126665.org.readthedocs.build/