4.4 Recall
Some key points in this chapter are the following:
-
Raising an exception happens when something goes wrong. We looked at division by zero as an example. Exceptions can also be raised with the raise statement.
-
The effects of an exception are to interrupt the normal sequential execution of statements. It saves us from having to write a lot of if statements to check to see whether things can possibly work or whether something actually failed.
-
Handling exceptions is done with the try: statement, which has an except: clause for each kind of exception we want to handle.
-
The exception hierarchy follows object-oriented design patterns to define a number of subclasses of the Exception class we can work with. Some additional exceptions, SystemExit and KeyboardInterrupt, are not subclasses of the Exception class; handling these exceptions can introduce risks and doesn...