How To Use the Python Debugger aka pdb

I have been using the Python Debugger aka pdb docs for 2.7/docs for 3.5 a lot recently and wanted to share a cheat sheet I found and also the common commands I use.

The cheatsheet:

pdb cheatsheet

The easiest thing to do is put the following in your code somewhere:

    import pdb; pdb.set_trace()

Then when you run it, it will stop there and you can step through the code a line at a time. The l(ist) command will show you 11 lines of code around the current line is the one I use the most. s(tep), n(ext), r(eturn) are some other I use regularly.

Once the debugger is up, you can check the stacktrace w(where), variable values a(rgs) or [variable_name] or many other things. Please check the documentation or the cheatsheet image above.

A much more in-depth usage of pdb can be found here

Cheatsheet image credit

Jason Meridth


My name is Jason Meridth. I am a continuously learning senior software developer/team lead/development manager trying to not let best be the enemy of better. I reserve the right to change my mind upon obtaining more information. I am also the owner and principal software consultant at Meridth, LLC. If you have any software, hardward, networking, process, etc needs please don't hesitate to reach out to me.

Raspberry Pi Kubernetes Cluster - Part 1

HowdyThis is going to be the first post about my setup of a Raspberry Pi Kubernetes Cluster. I saw a post by [Hart Hoover](https://harth...… Continue reading

SSH - Too Many Authentication Failures

Published on March 28, 2018

Clear DNS Cache In Chrome

Published on March 27, 2018