[Python-ideas] Enable tab completion for interactive sessions
Guido van Rossum
guido at python.org
Mon Nov 12 17:51:40 CET 2007
You can already enable this by copying those few lines into your
$PYTHONSTARTUP file. People who are truly into completion should be
using iPython anyway. :-)
On Nov 11, 2007 12:43 PM, Christian Heimes <lists at cheimes.de> wrote:
> Hello fellow Pythonistas!
>
> Python has a very useful feature a lot of people don't know about. It's
> tab completion for the interactive shell.
> http://docs.python.org/lib/module-rlcompleter.html
>
> Tab completion is very useful for introspection and quick tests in an
> interactive shell. rlcompleter isn't enable by default - and it
> shouldn't. But I like to add a cmd line option and an env var to load
> and enable the rlcompleter in an interactive session.
>
> The right place to enable the feature is in
>
> Modules/main.c:460
> if ((Py_InspectFlag || (command == NULL && filename == NULL && module ==
> NULL)) && isatty(fileno(stdin))) {
>
> code run when -i is given or neither command nor filename nor module
> is set and stdin is an interactive terminal.
>
> }
>
> At the moment the code block loads just the readline module. I also like
> to load the rlcompleter module and invoke readline.parse_and_bind("tab:
> complete") there.
>
> Options:
> (1) always enable tab completion for interactive shells w/o a command,
> module and filename.
> (2) only enable rlcompleter when the -i flag or PYTHONINTERACTIVE env
> var is set.
> (3) add a new command flag and env var to enable the completer when (1)
> or (2) is true
>
> Christian
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-ideas
mailing list