This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: rlcompleter tab completion in pdb
Type: enhancement Stage: patch review
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, rockyb, stephenemslie, tshepang
Priority: normal Keywords: patch

Created on 2007-01-22 11:52 by stephenemslie, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pdb-51745-tabcomplete.patch stephenemslie, 2007-01-22 11:52 tab completion patch for pdb rev. 51745
Messages (4)
msg51775 - (view) Author: Stephen Emslie (stephenemslie) Date: 2007-01-22 11:52
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:
http://mail.python.org/pipermail/python-ideas/2007-January/000084.html

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
msg51776 - (view) Author: Rocky Bernstein (rockyb) Date: 2007-01-28 02:48
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? 
msg51777 - (view) Author: Stephen Emslie (stephenemslie) Date: 2007-02-02 16:30
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 :)

msg157256 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2012-04-01 05:52
Meanwhile I've added more comprehensive tab-completion to 3.3 for #14210.
History
Date User Action Args
2022-04-11 14:56:22adminsetgithub: 44493
2012-04-01 05:52:51georg.brandlsetstatus: open -> closed
resolution: out of date
messages: + msg157256
2012-03-31 23:35:29pitrousetnosy: + georg.brandl
stage: test needed -> patch review

versions: + Python 3.3, - Python 3.2
2012-03-06 14:12:44tshepangsetnosy: + tshepang
2010-08-09 03:47:26terry.reedysetversions: + Python 3.2, - Python 3.1, Python 2.7
2009-03-30 19:04:39ajaksu2setstage: test needed
type: enhancement
versions: + Python 3.1, Python 2.7, - Python 2.6
2007-01-22 11:52:40stephenemsliecreate