Readline and unwanted filename completion

Michael Hudson mwh at python.net
Fri Feb 1 11:46:12 CET 2002


Simon Budig <Simon.Budig at unix-ag.org> writes:

> Hi all.
> 
> Something is broken with the completion of readline:

The more I learn about readline, the less I like about it.  Not that
I'd want to live without it, of course.

> It seems that readline has a fallback to filename completion when
> no matches are available. Even if I use my own completion function:
> 
> >>> def nullcompleter (text, state):
> ...    print "\nBuh!"

<aside>
That's probably a bad idea; you have no idea what state the terminal
will be in when this function gets called...
</aside>

> ...    return None
> ... 
> >>> rlcompleter.readline.set_completer(nullcompleter)
> >>> foo<TAB>
> Buh!
> <TAB>
> Buh!
> 
> foo.gif     foo.txt     foo2.gif    foobar.jpg  foot        
> >>> foo
> 
> there is this filename fallback.
> 
> Is this a known Problem? 

Well, I knew about it.  I don't regard it as a huge problem.

> Is there an evil hack to avoid this?

Dunno.  Doubt it, somehow.  You'll need to look at the documentation
for readline, though.

Cheers,
M.

-- 
40. There are two ways to write error-free programs; only the third
    one works.
  -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html



More information about the Python-list mailing list