The beauty of Pdb

I never used Pdb much. I always thought that I had to run my whole script through the debugger, set some breakpoints through obscure commands and whatnot. But it is not the case. I can do simply this:

#!/usr/bin/env python
import pdb

Now you run your script as usual, and it stops at the pdb.set_trace() line and opens up a Pdb prompt. Then you can go line by line, explore and set variable contents and find out the source of your problem. Great! This approach is convenient and easy to use.

You need to know just a several basic commands to be able to do quite a lot in the Pdb shell. Read this 10-minute introduction, it’s worth it: Debugging in Python


Flattr this

The beauty of Pdb

IPython GUI

Did you know that IPython has GUI? I didn’t. Then I’ve found ipython-gui package by accident. Wow, what is this?

This package contains the gui of ipython, which requires PyQt.

Nice, let’s try that out. I installed ipython-gui and… nothing. No new desktop launcher installed. No new executable installed. No new man page. No documentation of any kind. Nothing. Inspecting man ipython yielded same (no) results.

After dozens minutes spent Googling, I finally found the magic command:

$ ipython qtconsole

Hah, you are no match for me, ipython developers, I’ve found it in the end!

So once we know how to run it, what does it do? Well it is an improved IPython console. Main features I noticed in the first few minutes:

  • Syntax highlighting.
  • Tab completion hints disappear nicely and don’t “reset” your current line.
  • Methods docstrings are shown in the form of tooltips immediately after typing the opening parenthesis.
  • True multi-line editing support. You can finally invoke a multi-line command from history and easily change a single line. Yes!


Flattr this

IPython GUI