Debugging with pdb

Most of the Python developers reading this book might already be aware of the usage of pdb, that is, the Python debugger. For those who are not aware of it, pdb is an interactive source code debugger for Python programs. We can set breakpoints wherever needed, debug using single-stepping at the source line level, and inspect the stack frames.

Many new developers might be of the opinion that the job of a debugger can be handled using a logger, but debuggers provide a much deeper insight into the flow of control and preserve the state at each step, and hence, save a lot of development time.

Getting ready

We will use Python's built-in pdb module for this recipe and use it in our application from the last recipe.

How to do it…

Using ...

Get Flask Framework Cookbook 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.