hitting TAB inserts ./ in interactive mode ?

Nik Krumm nkrumm at gmail.com
Mon Sep 20 13:26:18 EDT 2010


On Sep 18, 11:28 am, Ned Deily <n... at acm.org> wrote:
> In article <i71rq5$4t... at lust.ihug.co.nz>,
>  Lawrence D'Oliveiro <l... at geek-central.gen.new_zealand> wrote:
>
> > In message <mailman.850.1284782522.29448.python-l... at python.org>, Ned Deily
> > wrote:
> > >     try:
> > >         importreadline
> > >     except ImportError:
> > >         print("Modulereadlinenot available.")
> > >     else:
> > >         import rlcompleter
> > >        readline.parse_and_bind("tab: complete")
>
> > > Note the print() form which works with either Python 2 or 3.
> > You should be writing diagnostics to stderr, not stdout.
>
> In general, sure.   Statements in a PYTHONSTARTUP file, like here, are
> only executed in interactive mode and it isn't likely that someone is
> going to be redirecting stdout or stderr; that would kind of defeat the
> purpose ofreadlinecompletion functions which is what this is all
> about.  But, if you feel strongly about it, I'm sure a contributed patch
> to improve the rlcompleter documentation would be welcome.
>
> --
>  Ned Deily,
>  n... at acm.org

Hi, Thanks for the replies.

The issue isn't with readline. The readline module or rlcompleter
module are both available, and loading them has no effect on the
behavior of tab:


>>> import readline
[Now i hit tab...]
>>> ./
  File "<stdin>", line 1
    ./
    ^
SyntaxError: invalid syntax

[Hit tab twice...]
>>> ./
./.bash_history         ./.bash_profile         ./.bash_profile.pysave  ./.CFUserTextEncoding   ./.cups                 ./.dropbox
./.DS_Store             ./.fontconfig           ./.ipython              ./.lesshst              ./.ssh                  ./.subversion
./.Trash                ./.Xauthority           ./
Desktop               ./Documents             ./
Downloads             ./inputrc
./Library               ./Movies                ./
Music                 ./Pictures              ./
Public                ./python
./Sites
>>> ./

>>> import rlcompleter
>>> pri[TAB]--> completes
>>> if testvar:
... [one TAB: nothing], [two TABs: "Display all 179 possibilities y/
n?"] (Note: here i need it to insert a tab, just as it should!)

So this ostensibly makes it very hard to write or paste any code into
the command line!

any further ideas? Thanks again
~N



More information about the Python-list mailing list