Debugging Python code

Much of a programmer’s time is spent debugging code than writing one. While I agree that it’s not a great thing, we can’t do much about it. But what we can do is maybe make this process more efficient and fun. In this post, we will try to discuss some techniques that can be useful for debugging. The order goes from a beginner level to a more advanced one. Using print Caution: This is not one of the recommended ways to debug things....

May 1, 2021 · 6 min

Enabling tab completion in pdb

I will admit being a big fan of pdb, and the debugging functionalities it provides. It still could do more by adding tab completion to guess attributes for python objects. In this post, we will try to address this caveat. Setting up Tab Completion Create a .pdbrc in your home directory. Add the following contents to the file # this adds tab completion import rlcompleter __import__('pdb').Pdb.complete = rlcompleter.Completer(locals()).complete Just save this file and use breakpoint(or import pdb;pdb....

April 1, 2021 · 1 min