[Patches] [ python-Patches-1641544 ] rlcompleter tab completion in pdb

SourceForge.net noreply at sourceforge.net
Fri Feb 2 17:30:31 CET 2007

Patches item #1641544, was opened at 2007-01-22 11:52
Message generated for change (Comment added) made by stephenemslie
You can respond by visiting: 

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Stephen Emslie (stephenemslie)
Assigned to: Nobody/Anonymous (nobody)
Summary: rlcompleter tab completion in pdb

Initial Comment:
By default, Pdb and other instances of Cmd complete names for their commands. However in the context of pdb, I think it is more useful to complete identifiers and keywords in its current scope than to complete names of commands (most of which have single letter abbreviations). I believe this makes pdb a far more usable introspection tool.

I have discussed this proposal on the python-ideas list:

This patch implements the following:
  - creates an rlcompleter instance on Pdb if readline is available
  - adds a 'complete' method to the Pdb class. The only difference with rlcompleter's default behaviour is that is also updates rlcompleter's namespace to reflect the current local and global namespace, which is necessary because pdb changes scope as it steps through a program

This is a patch against python/Lib/pdb.py rev. 51745


>Comment By: Stephen Emslie (stephenemslie)
Date: 2007-02-02 16:30

Logged In: YES 
Originator: YES

Thanks for your comments, and thanks for pointing out pydb

I agree that debugger commands should also belong in the completion
namespace. I'll have a look at adding that to the patch.

> The second problem I have is that completion is not all that sensitive
to the preceding context.

The idea is that the namespace that is available to the completer at any
time will be the same as the local and global identifiers and keywords that
are available in the same scope. I think it makes sense to complete
everything that is valid in the current scope because that makes for a more
useful introspection tool. Thats what frame.f_locals and frame.f_globals
are about (if foo and bar are available in the current scope, and you step
into a function outside of that scope then foo and bar will no longer be
available in the completer's namespace). I notice this is also used in
pydb's complete method under certain circumstances.

I'll definitely take a closer look at pydb. I probably wouldn't have
needed to write this if I'd known about it before :)


Comment By: Rocky Bernstein (rockyb)
Date: 2007-01-28 02:48

Logged In: YES 
Originator: NO

I experimented with this a little in the pydb variant
(http://bashdb.sf.net/pydb). Some observations. First, one can include the
debugger commands into the namespace without too much trouble. See what's
checked into CVS for pydb; In particular look at the complete method of
pydbbdb. (Personally, I think adding debugger commands to the list of
completions is a little more honest.)

The second problem I have is that completion is not all that sensitive to
the preceding context.  If the line begins "step" or "1 + ", is it really
correct to list all valid symbols? 


You can respond by visiting: 

More information about the Patches mailing list