]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Docs: except with multiple exceptions parentheses not required (#145848)
authorMaurizio Sambati <duilio@users.noreply.github.com>
Fri, 13 Mar 2026 09:40:20 +0000 (10:40 +0100)
committerGitHub <noreply@github.com>
Fri, 13 Mar 2026 09:40:20 +0000 (05:40 -0400)
As of PEP 758 the except statement doesn't require parentheses anymore for exception tuples.

See: https://peps.python.org/pep-0758/

Doc/tutorial/errors.rst

index 1c20fa2f0b6ae588ab85338da29e6fda50948abe..ae21dfdbf0ac444dcb99fc73a736bb3543369455 100644 (file)
@@ -121,9 +121,9 @@ A :keyword:`try` statement may have more than one *except clause*, to specify
 handlers for different exceptions.  At most one handler will be executed.
 Handlers only handle exceptions that occur in the corresponding *try clause*,
 not in other handlers of the same :keyword:`!try` statement.  An *except clause*
-may name multiple exceptions as a parenthesized tuple, for example::
+may name multiple exceptions, for example::
 
-   ... except (RuntimeError, TypeError, NameError):
+   ... except RuntimeError, TypeError, NameError:
    ...     pass
 
 A class in an :keyword:`except` clause matches exceptions which are instances of the