How to test Python readline completion?

前端 未结 4 1227
借酒劲吻你
借酒劲吻你 2021-02-19 13:25

I\'m writing a command-line interface in Python. It uses the readline module to provide command history and completion.

While everything works fine in interactive mode,

4条回答
  •  名媛妹妹
    2021-02-19 14:14

    rlcompleter might accomplish what you want

    From the documentation:

    The rlcompleter module is designed for use with Python’s interactive mode. A user can add the following lines to his or her initialization file (identified by the PYTHONSTARTUP environment variable) to get automatic Tab completion:

    try:
        import readline
    except ImportError:
        print "Module readline not available."
    else:
        import rlcompleter
        readline.parse_and_bind("tab: complete")
    

    https://docs.python.org/2/library/rlcompleter.html

提交回复
热议问题