gh-126664: Use else instead of finally in "The with statement" documentation.#126665
gh-126664: Use else instead of finally in "The with statement" documentation.#126665gpshead merged 1 commit intopython:mainfrom vivodi:patch-1
else instead of finally in "The with statement" documentation.#126665Conversation
…nt" documentation. (pythonGH-126665) (cherry picked from commit 25257d6) Co-authored-by: vivodi <103735539+vivodi@users.noreply.github.com>
|
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 <103735539+vivodi@users.noreply.github.com>
|
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 <greg@krypto.org>
…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 <greg@krypto.org>
…aining "with" (python#128169) Revert "pythongh-126664: Use `else` instead of `finally` in "The with statement" documentation. (pythonGH-126665)" This reverts commit 25257d6.
…laining "with" (GH-128169) (#128170) gh-126664: revert: Use `else` instead of `finally` in docs explaining "with" (GH-128169) Revert "gh-126664: Use `else` instead of `finally` in "The with statement" documentation. (GH-126665)" This reverts commit 25257d6. (cherry picked from commit 228f275) Co-authored-by: Gregory P. Smith <greg@krypto.org>
…laining "with" (GH-128169) (#128171) gh-126664: revert: Use `else` instead of `finally` in docs explaining "with" (GH-128169) Revert "gh-126664: Use `else` instead of `finally` in "The with statement" documentation. (GH-126665)" This reverts commit 25257d6. (cherry picked from commit 228f275) Co-authored-by: Gregory P. Smith <greg@krypto.org>
…aining "with" (python#128169) Revert "pythongh-126664: Use `else` instead of `finally` in "The with statement" documentation. (pythonGH-126665)" This reverts commit 25257d6.
…nt" documentation. (pythonGH-126665)
Documentation
In 8.5 The
withstatement, we can useelseinstead offinally.is semantically equivalent to:
elseinstead offinallyin "The with statement" documentation. #126664📚 Documentation preview 📚: https://cpython-previews--126665.org.readthedocs.build/