Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: BΓ©nΓ©dikt Tran <[email protected]>
Co-authored-by: Brian Schubert <[email protected]>
  • Loading branch information
3 people authored Mar 29, 2025
commit 0d09ad2e1f79d85b58b10d6156ac0e9f4764267d
23 changes: 13 additions & 10 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,28 +90,31 @@ If you encounter :exc:`NameError`\s or pickling errors coming out of
New features
============

.. _whatsnew314-pep758:

PEP 758 – Allow except and except* expressions without parentheses
Comment thread
pablogsal marked this conversation as resolved.
------------------------------------------------------------------

The :keyword:`except` and :keyword:`except*` expressions now allow
The :keyword:`except` and :keyword:`except* <except_star>` expressions now allow
parentheses to be omitted when there is only one exception type.
Comment thread
pablogsal marked this conversation as resolved.
Outdated
Comment thread
pablogsal marked this conversation as resolved.
Outdated
For example the following expressions are now valid:

.. code-block:: python

try:
release_new_sleep_token_album()
except AlbumNotFound, SongsTooGoodToBeReleased:
print("Sorry, no new album this year.")
try:
release_new_sleep_token_album()
except AlbumNotFound, SongsTooGoodToBeReleased:
print("Sorry, no new album this year.")

Comment thread
pablogsal marked this conversation as resolved.
try:
release_new_sleep_token_album()
except* AlbumNotFound, SongsTooGoodToBeReleased:
print("Sorry, no new album this year.")
try:
release_new_sleep_token_album()
except* AlbumNotFound, SongsTooGoodToBeReleased:
print("Sorry, no new album this year.")
Comment thread
pablogsal marked this conversation as resolved.

Check :pep:`758` for more details.

(Contributed by Pablo Galindo and Brett Cannon in :issue:`131831`.)
(Contributed by Pablo Galindo and Brett Cannon in :gh:`131831`.)


.. _whatsnew314-pep649:

Expand Down
Loading