mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
[3.12] gh-117597: Clarify exception handling in the tutorial (GH-117681) (#117700)
(cherry picked from commit a05068db0c
)
Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
This commit is contained in:
parent
af034dd150
commit
e46fd7257a
1 changed files with 3 additions and 3 deletions
|
@ -119,9 +119,9 @@ may name multiple exceptions as a parenthesized tuple, for example::
|
|||
... except (RuntimeError, TypeError, NameError):
|
||||
... pass
|
||||
|
||||
A class in an :keyword:`except` clause is compatible with an exception if it is
|
||||
the same class or a base class thereof (but not the other way around --- an
|
||||
*except clause* listing a derived class is not compatible with a base class).
|
||||
A class in an :keyword:`except` clause matches exceptions which are instances of the
|
||||
class itself or one of its derived classes (but not the other way around --- an
|
||||
*except clause* listing a derived class does not match instances of its base classes).
|
||||
For example, the following code will print B, C, D in that order::
|
||||
|
||||
class B(Exception):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue