Exceptions, Logging, and Debugging

Learning PathSkills: Python, Exceptions, Logging, Debugging, pdb, raise, Built-in Exceptions, Error Handling

A person sitting in front of a computer, reading logs from a program, with an alarm light going off that indicates that an issue has been logged

In this learning path, you’ll learn how to handle exceptions, log events, and debug your Python code. You’ll start with exception handling using raise and built-in exceptions, then explore Python’s logging module and its source code. Finally, you’ll learn to debug with pdb.

Exceptions, Logging, and Debugging

Learning Path ⋅ 7 Resources

Exception Handling

Learn how Python handles errors through exceptions. You’ll explore how to raise, catch, and work with both custom and built-in exception types.

Title image for Raising and Handling Python Exceptions (An Introduction to Python Exceptions)

Course

Raising and Handling Python Exceptions

Learn what an exception is and how it differs from a syntax error. You'll learn about raising exceptions, making assertions, and catching exceptions to change the control flow of your program using the try, except, else, and finally keywords.

Title image for Using raise for Effective Exceptions (Python's raise: Effectively Raising Exceptions in Your Code)

Course

Using raise for Effective Exceptions

Learn how to raise exceptions in Python, which will improve your ability to efficiently handle errors and exceptional situations in your code. This way, you'll write more reliable, robust, and maintainable code.

Title image for Working With Python's Built-in Exceptions (Python's Built-In Exceptions: A Walkthrough With Examples)

Course

Working With Python's Built-in Exceptions

Learn the most common built-in Python exceptions, when they occur, how to handle them, and how to raise them properly in your code.

Title image for Handling or Preventing Errors in Python: LBYL vs EAFP (LBYL vs EAFP: Preventing or Handling Errors in Python)

Course

Handling or Preventing Errors in Python: LBYL vs EAFP

Learn about two popular coding styles in Python: Look Before You Leap (LBYL) and Easier to Ask Forgiveness than Permission (EAFP). You can use these styles to deal with errors and exceptional situations in your code. You'll dive into the discussion on LBYL vs EAFP in Python.

Logging

Python’s logging module helps you track events and diagnose issues in your applications. You’ll learn to configure logging and explore how it works under the hood.

Title image for Logging Inside Python (Logging in Python)

Course

Logging Inside Python

Learn why and how to get started with Python's powerful logging module to meet the needs of beginners and enterprise teams alike.

Title image for Logging in Python (Logging in Python)

Interactive Quiz

Logging in Python

Title image for Python Logging: A Stroll Through the Source Code (Python Logging: A Stroll Through the Source Code)

Tutorial

Python Logging: A Stroll Through the Source Code

Learn about how the Python logging package is designed from an OOP perspective. You'll walk line by line through the source code and become better equipped to know what your code is doing.

Debugging

When something goes wrong, you need to find and fix the problem. Learn how to use Python’s built-in debugger, pdb, to step through your code and inspect variables.

Title image for Debugging in Python With pdb (Python Development Tools Artwork)

Course

Debugging in Python With pdb

Learn the basics of using pdb, Python's interactive source code debugger. pdb is a great tool for tracking down hard-to-find bugs, and it allows you to fix faulty code more quickly.

Congratulations on completing this learning path! You’ve learned to handle exceptions, log events, and debug Python code using pdb.

Continue your intermediate Python journey with the next learning path:

Learning Path

Classic Data Structures and Algorithms

20 Resources ⋅ Skills: Python, Data Structures, Stacks, Queues, Linked Lists, Hash Tables, Enums, Search Algorithms, Sorting Algorithms, Collections

You might also be interested in these related learning paths:

Got feedback on this learning path?

Looking for real-time conversation? Visit the Real Python Community Chat or join the next “Office Hours” Live Q&A Session. Happy Pythoning!

« Browse All Learning Paths