Loading video player…

Working With Python's Built-in Exceptions (Overview)

Python has a complete set of built-in exceptions that provide a quick and efficient way to handle errors and exceptional situations that may happen in your code. Knowing the most commonly used built-in exceptions is key for you as a Python developer. This knowledge will help you debug code because each exception has a specific meaning that can shed light on your debugging process.

You’ll also be able to handle and raise most of the built-in exceptions in your Python code, which is a great way to deal with errors and exceptional situations without having to create your own custom exceptions.

In this video course, you’ll:

  • Learn what errors and exceptions are in Python
  • Understand how Python organizes the built-in exceptions in a class hierarchy
  • Explore the most commonly used built-in exceptions
  • Learn how to handle and raise built-in exceptions in your code

Resource linked in this lesson: Python Exceptions: An Introduction

Download

Course Slides (.pdf)

8.7 MB
Download

Sample Code (.zip)

4.8 KB

00:00 Why hello there. Welcome to Working With Python’s Built-in Exceptions. My name is Joseph, and I’ll be here to shine a light on the dark cobweb recesses of Python exceptions. As coders, we’re all familiar with exceptions and errors.

00:14 Maybe we fear them, maybe we seek to avoid them at all costs, or maybe we hope to handle them. But while any error can mean the sudden end to your program, not all errors are made equal.

00:25 By understanding the variety of built-in exceptions available in Python, you can, in turn, understand the nuances of the situations in which they occur. And this is essential for writing effective resilient production code.

00:39 Throughout this course, you’ll learn the actual differences between what we consider errors versus exceptions, techniques for both handling and raising exceptions in your code.

00:50 How to navigate Python’s hierarchy of built-in exceptions, when and where you’ll encounter the most common exceptions, and how understanding built-in exceptions can help you write more maintainable Python programs.

01:04 While we will be diving deep with explanations, some background knowledge with Python concepts related to exceptions would be beneficial. Concepts like object-oriented programming in Python, classes and inheritance, try-except blocks, and the raise statement.

01:21 Also, this course is specifically about understanding the different types of exceptions built into Python. If you want a deeper refresher on errors and exception handling in general, check out Python Exceptions: An Introduction.

01:34 And one last note before we get started. I’ll be using Python 3.13 in this course. Starting with Python 3.10, error messages have become a lot more detailed.

01:44 So if you’re watching this using an older version of Python, you may not see as much information on your screen.

01:49 And if you’re using a future version of Python, well, you might see even more detail or far enough in the future, maybe AI fixes errors for you or something like that.

01:58 But for those of you not yet living in that utopia, well, follow me to the next lesson where we’ll break down errors and exceptions in Python.

Become a Member to join the conversation.