python tab completion in windows

2019-02-10 07:12发布

I'm writing a cross-platform shell like program in python and I'd like to add custom tab-completion actions. On Unix systems I can use the built-in readline module and use code like the following to specify a list of possible completions when I hit the TAB key:

import readline
readline.parse_and_bind( 'tab: complete' )
readline.set_completer( ... )

How can I do this on Windows? I'd like to avoid relying on 3rd-party packages if possible. If no solution exists is it possible to simply trap TAB key press so that I can implement my own from scratch?

3条回答
Rolldiameter
2楼-- · 2019-02-10 07:45

Do u have a look at PyReadline: a ctypes-based readline for Windows? Although 3rd-party packages is NOT your option, maybe it's useful for build one's own, isn't it:).

查看更多
倾城 Initia
3楼-- · 2019-02-10 07:49

Another possibility to check out is readline.py.

查看更多
三岁会撩人
4楼-- · 2019-02-10 07:56

you could look at how ipython does it with pyreadline as well, maybe

查看更多
登录 后发表回答