Debugging basics and debugging python scripts with pdb
Arfat Salman (~ArfatSalman) |
A lot of budding programmers use
print() function or
logging module to display the state of the program. However, it soon becomes untenable to reason about the program in a barrage of print statements. At that time, a debugger is a must.
Debuggers are a better and structured way to inspect a program. A practical and basic understanding of debuggers will help in locating bugs easily and save developer's time and unnecessary frustration.
In this talk, we are going to learn the terminology associated with debugging and explore the most commonly used commands of pdb.
Outline of the talk -
Introduction (5-7 mins)
- About logging and print statements
- Why debuggers?
- When it becomes a necessity .
PDB Introduction ( 5 mins)
- How to use PDB in a script
- Basic command with demos
Some Intermediate PDB commands, techniques and tools (15 - 20 mins) .
- setting and clearing breakpoints
- up and down
Conclusion (2 mins)
- Where to go from here
- Some leads into debugging using gdb and tracing tools
I would have a small script that I would continuously use to demonstrate various commands. So I would shuffle between my slides and the interpreter.
Beginner experience and interest towards python programming. Ideal for college students or people who just started programming in Python.
I'm currently a Senior Web Developer and Curriculum Designer at Pesto Tech. I've programmed in Python and Flask since the last 3 years. Open source enthusiast, and frequent blogger.