python tab completion in windows

纵然是瞬间 提交于 2019-11-30 15:34:18

问题


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?


回答1:


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:).




回答2:


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




回答3:


Another possibility to check out is readline.py.



来源:https://stackoverflow.com/questions/1081405/python-tab-completion-in-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!