Practice mode Python

Which class should a user-defined exception normally inherit from?

Correct answer C. Exception

Explanation

The documentation advises that user-defined exceptions should derive from Exception, directly or indirectly. Inheriting from BaseException would bypass normal except Exception handlers, and a plain object subclass cannot be raised at all. Python has no built-in class named Error, although many modules define their own error classes.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.