Prior to Python 3.7 debugging was done using pdb which is available through Python’s Standard Library. Now, when we want to debug some code, we simply insert breakpoint() in the area we wish to debug. When Python’s interpreter sees this, it will halt the execution of the code at that particular spot and will inform you what it will execute next.

We can then inspect variables in order to find out what are the values that these variables hold. You also can use the following shortcut keys:

  • n - Go to the next line. When using this shortcut key, the debugger will not go into functions should it come upon a function call.

  • s - Go to the next line. Unlike the previous shortcut, using this shortcut, the debugger will go into a function.

  • c - This shortcut continues execution of the program in normal fashion, without going one step at a time.

  • q - Stops the program’s execution.