DEBUGGING - NTRODUCTION TO PROGRAMMING WITH PYTHON (2015)

INTRODUCTION TO PROGRAMMING WITH PYTHON (2015)

CHAPTER 11. DEBUGGING

Codes remind us of the importance of paying attention in English grammar lessons, and how our overreliance on auto-correct features in word processing software has made us susceptible to overlooking small mistakes — a comma here, a colon there, and a misspelled variable there, among others.

Mistakes, weather small or large can pull the brakes on a program. As a result, your code will not run at all, display errors, or give obnoxious results. This is where you have to troubleshoot the program, locate the problem, and correct it.

In programming lingo, that’s called debugging your program.

Small mistakes such as wrong syntax or declaring non-existing variables, or more fundamental mistakes such as insufficient understanding of the problem (and hence the objects that need to be created and their interaction), and incorrect flow of data can make the code dysfunctional.

Given that only you can best understand your code, you will often find yourself in a position where you alone are right person to save your code. However, decades of testing have given us a few tips and tricks for debugging your code.

However, before we move into the tips, it is important that you download your first debugger.

DOWNLOAD A DEBUGGER

Why?

Python already ships in with its built-in debugger.

Yes, Python comes equipped with a debugger, sporting a basic command line interface and with various features and options. However, it lacks certain features that will simplify debugging for beginners, including stack traces and differentiating coloring for different types of code.

So, here’s a better option for a debugging tool.

Download Pudb 2015.3, a full screen console based program debugger. It has a modern GUI-based environment, and allows you to debug your code right where you write it: on the terminal.