Wednesday, 21 August 2013

Python Tab Completion Pager

Python Tab Completion Pager

I've tried searching for this answer, and either don't have the right word
combination, or simply can't find, but I apologize if it's a repeat:
When in a python interpreter (running python[3] from the command line,
i.e. not IPython or anything), how do I get the interpreter to "page" my
tab completions when there are too many to fit on one screen?
For example, if I
import os
os.<tab>
on some computers, it will fill the screen with columnar output of all
os.* options, and the bottom line is "More" (as if I've run 'more' or
'less' on the output, so to speak), and I page through with Enter or the
space bar. On my current OS, though, it just spits out all the
possibilities, which requires me to scroll up to see everything.
Is there a simple function that I should have included in, say, my
.pythonstartup that would alleviate this? All I have in there now is:
import readline
readline.parse_and_bind("tab: complete")
which obviously isn't enough to get what I want; I get tab completion, but
not paged output.

No comments:

Post a Comment