How do I get the currently installed tab completion function?

Chris Angelico rosuav at gmail.com
Mon Jun 22 22:02:33 EDT 2015


On Tue, Jun 23, 2015 at 11:41 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> On Tue, 23 Jun 2015 11:23 am, Chris Angelico wrote:
>
>> On Tue, Jun 23, 2015 at 11:02 AM, Steven D'Aprano <steve at pearwood.info>
>> wrote:
>>> How do I get the currently installed completer?
>>>
>>> Solutions for any version of Python acceptable, but if they work all the
>>> way back to 2.4 or older, even better.
>>
>> Whether there's a way to avoid the whole try/finally I can't say, but
>> I just went looking for the obvious "readline.get_completer()", and it
>> does seem to be there. Is there something I'm missing here?
>
> No, but there's obviously something *I'm* missing.
>
> I don't know how I missed that :-(
>
> It's especially embarrassing because it is available all the way back to
> version 2.4, which is exactly what I need.
>
>
> Sorry for the noise.

That's still only the lesser option, of course. Better would be a way
to say raw_input("prompt? ", completer=filename_completer) but that's
not an option, so it'd have to be an explicit readline.something()
call. I can't find any way to actually ask the readline module to read
a line, though, but given that my experience with that module is
effectively zip, someone else may well be able to offer a superior
suggestion.

ChrisA



More information about the Python-list mailing list