Skip to main content

Pdb++ and rlcompleter_ng

When hacking on PyPy, I spend a lot of time inside pdb; thus, I tried to create a more comfortable environment where I can pass my nights :-).

As a result, I wrote two modules:

  •, which extends the default behaviour of pdb, by adding some commands and some fancy features such as syntax highlight and powerful tab completion; is meant to be placed somewhere in your PYTHONPATH, in order to override the default version of shipped with the stdlib;
  •, whose most important feature is the ability to show coloured completions depending on the type of the objects.

To find more informations about those modules and how to install them, have a look at their docstrings.

It's important to underline that these modules are not PyPy specific, and they work perfectly also on top of CPython.


Brodie Rao wrote on 2008-06-22 20:57:

That's pretty impressive, but I think having to modify readline itself in order to do this is a little excessive. readline's completion capabilities are pretty limited. I wonder if there are any better alternatives that could be used with Python.

I have something similar set up for my Python prompt: -- it allows completion and indentation, it persists command history with readline, and it prints documentation if you try to evaluate certain objects like functions, classes, and methods. It also pretty-prints output, but I'm still trying to tweak it so it's aware of the terminal width.

Antonio Cuni wrote on 2008-06-23 12:32:

yes, I agree that having to modify readline is not too nice. I tried hard to avoid this but with bad luck :-/.

I suppose I could try to reimplement readline in Python, but I think it would be too much work; if you are aware of something already done, please let me know :-).

Pachi wrote on 2008-06-23 12:58:

would this work be suitable to inclusion in the standard pdb module?. That would be awesome.

Maciej Fijalkowski wrote on 2008-06-23 16:25:

There is readline implementation on top of pyrepl in pypy already :) PyPy by default does not use readline, but just uses this.

Paul wrote on 2008-06-24 22:00:

Nice job antonio. I'd clean the code up, conform to new-style classes and proper MRO handling. I'd also think about refactoring some of those names and find something better suited. Overall, awesome job man.

Unknown wrote on 2008-06-26 10:48:

This looks great. You've taken a step futher than my own attempts here:

Two small comments though: it crashes on startup without the right config in ~/ and once I got it started I see things like this when completing th tab:


but syntax highlighting seems to work perfectly. Thanks!

Antonio Cuni wrote on 2008-06-27 11:57:

@Stephen: as described in the docs of rlcompleter_ng, to use colorized completion you need to use a patched version of readline, there is no chance to get it working without that.

Could you describe in more details what problem did you encounter with ~/, so that I can fix it, please?

Anonymous wrote on 2008-12-10 20:26:

Antonio - I created a minor patch for which will allow it to run on both Python 2 and 3.

cool-RR wrote on 2011-05-05 18:39:

I was disappointed that pdb++ doesn't work on Windows. Apparently it uses the `termios` module which is not available on Windows.