2 ms·
One problem with tab completion is that you can no longer paste tab-indented snippets into the intepreter, or use tab to indent code you're typing. I put the fo
by Camillo 13y ago
One problem with tab completion is that you can no longer paste tab-indented snippets into the intepreter, or use tab to indent code you're typing. I put the following in my python startup file to fix the issue:
import readline, rlcompleter
readline.parse_and_bind("tab: complete")
readline.parse_and_bind('bind ^I rl_complete')
class MyCompleter(rlcompleter.Completer):
def complete(self, text, state):
if text.lstrip() == '':
if state == 0:
return text + '\t'
else:
return None
else:
return rlcompleter.Completer.complete(self, text, state)
readline.set_completer(MyCompleter().complete)
- alexpopescu 13y agoNiiiice!