Six Debugging Techniques for Python Programmers

Yang Zhou
TechToFreedom
Published in
5 min readAug 11, 2020

--

Six Debugging Techniques for Python Programmers

Introduction

It’s nearly impossible that a program can be written once and run perfectly all the time. Bugs and debugging are part of the daily lives of programmers. Therefore, to learn some useful debugging techniques is an important task for every developer. This post will introduce six debugging techniques for Python developers.

1. Print and Check

The simplest but powerful method is to print some particular variables and check their values are as expected or not.

As the above example shown, if we are not sure with a variable, we can just print and check it. After that, some modifications can be considered.

The biggest disadvantage of using print is that you have to delete it in the future. The program will be hard to read if there are print statements everywhere and the results will also contain a lot of garbage information. No worries, we have other techniques.

2. Assert and Check

--

--