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

jmeridth

My name is Jason Meridth. I am a continuously learning senior software developer/devops/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 2

Howdy again.Alright, my 8 port switch showed up so I was able to connect my raspberry 3B+ boards to my home network. I plugged it in wit...… Continue reading

Raspberry Pi Kubernetes Cluster - Part 1

Published on April 07, 2018

SSH - Too Many Authentication Failures

Published on March 28, 2018