[Announce] tabhistory - tab completion and command history

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Sep 1 16:44:59 CEST 2014

I am happy to announce an upgrade to the tabhistory module, which brings
advanced tab completion and command history to Python 2.4 through 3.3 and


Tab completion

* At the beginning of lines, pressing the TAB key indents the line.

* Inside strings, pressing TAB performs filename completion of the string.

* Following the "import" and "from" keywords, pressing TAB completes on
  modules and module attributes. For security, module attributes are only
  checked if the module has already been imported and is in the sys.modules

* Everywhere else, pressing TAB completes on keywords, built-ins, globals,
  and references of the form "name.name".

* Supports readline key binding and editing commands.

Command history

* Save command line history during interactive sessions, and automatically
  restore that history when you start up again.

* Use the up-arrow to call up previous commands, and down-arrow for 
  more recent ones.

* Display the last N command lines.

Where to get it

Clone the Mercurial repository:

hg clone https://code.google.com/p/tabhistory/

There is a single Python file, tabhistory.py. Put it somewhere on your
Python path, launch the interactive interpreter, and run:

import tabhistory

and it will be enabled.

If you don't have Mercurial, you can download the source code from here:



* This may not work on Windows at all. In theory, it might work if you
install the pyreadline third-party module, but I have no way of testing
this. Feedback from Windows users will be gratefully accepted.

* There may be some issues on Mac OS X or other Unixes which use libedit
instead of libreadline. I will be grateful for comments and bug fixes from
any libedit users.

* Python 3.0 is not officially supported (but it probably will work).

Bug reports, feature requests and other comments are welcome.


More information about the Python-list mailing list