S
Steven D'Aprano
I have set up readline completion as described here:
http://docs.python.org/library/rlcompleter.html
Now how do I indent blocks in the interactive interpreter? If I press the
TAB key, the completer prompts me instead of indenting:
....
Display all 182 possibilities? (y or n)
....
Surely I'm not stuck with indenting by manually typing spaces?
I thought I could add a wrapper around the rlcompleter method, like this:
.... if not text or text.isspace():
.... return "\t"
.... else:
.... return completer(text, state)
....
Completion appears to work if I have something in the line to start with,
e.g. if I type "whi" TAB "Tr" TAB I get "while True", but if I press TAB
on an empty line (intending to get an actual tab character for
indentation), it plays merry havoc with my session. All keyboard input
appears to be dead, eventually I used Ctrl-Z to interrupt the process and
killed it from the shell.
http://docs.python.org/library/rlcompleter.html
Now how do I indent blocks in the interactive interpreter? If I press the
TAB key, the completer prompts me instead of indenting:
....
Display all 182 possibilities? (y or n)
....
Surely I'm not stuck with indenting by manually typing spaces?
I thought I could add a wrapper around the rlcompleter method, like this:
.... if not text or text.isspace():
.... return "\t"
.... else:
.... return completer(text, state)
....
Completion appears to work if I have something in the line to start with,
e.g. if I type "whi" TAB "Tr" TAB I get "while True", but if I press TAB
on an empty line (intending to get an actual tab character for
indentation), it plays merry havoc with my session. All keyboard input
appears to be dead, eventually I used Ctrl-Z to interrupt the process and
killed it from the shell.