tab completion?

sjdevnull at yahoo.com sjdevnull at yahoo.com
Tue Mar 4 11:18:39 EST 2008


On Mar 4, 10:44 am, Ron DuPlain <ron.dupl... at gmail.com> wrote:
> On Mar 4, 10:13 am, Siddhant <siddhantg... at gmail.com> wrote:
>
> > Hi people.
> > I was just wondering if a tab-completion feature in python command
> > line interface would be helpful?
> > If yes, then how can I implement it?
> > Thanks,
> > Siddhant
>
> ipython provides auto tab completion.http://ipython.scipy.org/
>
> You can also get it by:
> $ easy_install ipython
>
> Run it using the command:
> $ ipython
>
> Is this what you want?

ipython also makes stack traces nearly unreadable by default (setting
"xmode Plain" in the ipythonrc fixed that) and tends to take up too
much vertical screen space, wants to colorize a lot of stuff, and has
a few other things that I was't fond of.  There's some nice stuff in
ipython (saving the return values of every line in the shell), but I
found trying to configure off all of the "magically helpful" stuff
that wound up being more annoying than useful was a fairly long job.

I found it easier just to turn on completion in the regular python
shell.  From my .pythonrc:

try:
    import readline
except ImportError:
    print "Module readline not available."
else:
    import rlcompleter
    readline.parse_and_bind("tab: complete")
del readline, rlcompleter

With that and persistent history I'm pretty happy:

import readline
histfile = os.path.join(os.environ["HOME"], ".pyhist")
try:
    readline.read_history_file(histfile)
except IOError:
    pass
import atexit
atexit.register(readline.write_history_file, histfile)
del os, histfile



More information about the Python-list mailing list