79589882

Date: 2025-04-24 05:46:09
Score: 2.5
Natty:
Report link

I've same question and found this via Google search. I know this is a 10 years old post but people like me might also find this post.

Now the latest Python document has clear instructions about derived exception instance:

https://docs.python.org/3/tutorial/errors.html#handling-exceptions

  1. A class in an except clause matches exceptions which are instances of the class itself or one of its derived classes.

  2. An except clause listing a derived class does not match instances of its base classes.

  3. The first matching except clause is triggered.

I'd say it's a lot more clear than the terms like "in turn" in old documents.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Me too answer (2.5): 've same question
Posted by: RichardLiu