Maltysen Maltysen - 3 months ago 7x
Python Question

Setting completekey=None removes up-arrow functionality

I'm trying to write a small REPL using the

library in Python. One of the features that it provides is automatic tab completion, which I do not want.

Luckily, the docs mention "If completekey is not None and readline is available, command completion is done automatically." So I set
when I instantiated my
subclass, which worked.

However, the main functionality of the
module, the use of
which gives support for up-arrow history, was also disabled, and now I'm back to

Why is this happening, and is there a solution?


The readline module is only imported if completekey has a non-None value. It looks like the only way to use readline and disable completion is to specify a do-nothing completer.

class CmdSubclass(Cmd):
    # Other configuration
    # ...

    def complete(self, *args):