Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python tab completion in windows

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?

like image 894
Nate Avatar asked Jul 04 '09 03:07

Nate


People also ask

Does Python have tab completion feature?

Tab Completion and History Editing. Completion of variable and module names is automatically enabled at interpreter startup so that the Tab key invokes the completion function; it looks at Python statement names, the current local variables, and the available module names.

How do I turn on autocomplete in Python?

(In Python Shell window, you can use TAB key besides the key combination of 'CTRL' and 'space' to invoke the built-in auto-completion feature.) Alternatively, you can choose the "Show Completions" in the main Edit menu to achieve the same as well.

How do I enable autocomplete in Python idle?

Python IDLE has basic code completion functionality. It can only autocomplete the names of functions and classes. To use autocompletion in the editor, just press the tab key after a sequence of text. The call tip will display as a popup note, reminding you how to append to a list.


1 Answers

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

like image 131
sunqiang Avatar answered Sep 29 '22 21:09

sunqiang