When writing computer programs, it is usually possible to discern between a normal course of events and something that’s exceptional (out of the ordinary). Such exceptional events might be errors (such as trying to divide a number by zero) or simply something you might not expect to happen very often. To handle such exceptional events, you might use conditionals everywhere the events might occur (for example, have your program check whether the denominator is zero for every division). However, this would not only be inefficient and inflexible but would also make the programs illegible. You might be tempted ...
© Magnus Lie Hetland 2017
Magnus Lie Hetland, Beginning Python, 10.1007/978-1-4842-0028-5_8
8. Exceptions
Magnus Lie Hetland1
(1)Trondheim, Norway
Get Beginning Python: From Novice to Professional, 3rd 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.