Python readline Auto

I want to implement auto-complete in Command Line Interface for the following :

Food : 
  Fruits:
    Apples
    Oranges
  Vegetables:
    Carrot
    Beetroot
  Snacks:
    Chocolate

The output for the <TAB> would be : food
and so on...

Commands would be like : Food Fruits Apples or Food Snacks Chocolate

Came across this https://pymotw.com/2/readline/ while googling. But I don't understand how begin/end works. And how it will change for further nesting.

Any sort of help is appreciated. (Writing code in python. Prefer to use readline library)


如果你使用像点击这样的库来制作你的CLI,你会得到这个主要是免费的http://click.pocoo.org/5/bashcomplete/

链接地址: http://www.djcxy.com/p/56430.html

上一篇: python类中的不可变属性和类型检查

下一篇: Python readline Auto