This post is a followup to my article The Basics of Exceptions in Python, but should make sense on its own as long as you are familiar with
Let’s cover a few more advanced aspects of the Python exception system. We’ll move a bit faster and talk at a higher level than we did in the last post.
Topics we’ll hit:
This post was originally meant to be a small part of my discussion of the Go programming language (coming soon) as a way of drawing contrast between Python and Go, but turned out to be extensive enough to justify its own post.
What exactly needs to be done in that “handling” step typically depends on what went wrong, and so there are many types of errors. Programmers can check the type of an error to determine what went wrong and react accordingly. Errors can be thought of as objects and their types as classes that can be subclassed like any other class. But unlike other data, they follow an error-specific path through the code, short-circuitiing functions all the way up the stack until handled.
When I first started going to the gym, I was self-conscious every second. There’s a particular code of unwritten rules in the weightroom. Having a mentor really helps, and without one, it’s easy to be so uncomfortable that you don’t want to come back.
Over the years I’d like to think I’ve picked up most of the “rules”. Here’s a list I wish someone had given me when I was starting.