9. Exception Handling
Exceptions are a solution to a difficult problem: How can programs deal with unexpected errors? For instance, what happens if a file disappears in the middle of being read because some other program on your computer has deleted it? Or what if the website your program is downloading pages from suddenly crashes?
In these and many other situations, what Python does is raise an exception. An exception is a special kind of error object that you can catch and then examine in order to determine how to handle the error.
Exceptions can change the flow of control of your program. Depending on when it occurs, an exception can cause the flow of control to jump out of ...
Get Python: Visual QuickStart Guide, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.