Debugging in Python

A guide to knowing and implementing the Python debugger module.

The Python module used to debug the code is called as “pdb”. It provides an interactive debugging program for Python programs. It has features that allow you to pause the program, check the values of different variables and watch the step-by-step execution of the program. This helps in finding bugs in the logic.

Let’s consider a code with an error to see how this works.

>>> import pdb

So as you can see there is an error because a list and integer cannot be added. Now we will set a trace using the module. So go to the line where there is an error and trace it. When this code is run, the interactive debugging environment is shown. Press ‘q’ to quit the debugging environment.

Source: Author
>>> a = [11,44,77]
>>> b = 1
>>> c = 9

Refer to the notebook here.

Beginner-level books to refer to learn Python:

Advance-level books to refer to learn Python:

Reach out to me: LinkedIn

Check out my other work: GitHub

Self-driven woman who wishes to deliver creative and engaging ideas and solutions in the field of technology.