ipy - Completion For Python Interactive
Bash has awesome command and file completion. I like that. Ruby people are just spoiled with irb.
Python can do that too.
Completion is handled by the
rlcompleter module, aided by the
readline library, and it is all set up with two lines of code.
Useful, but you want to have that set up automatically (if you can remember or can be bothered to type those liens every time you start
python, you have my deepest respects, yet I’m also slightly suspicious of your sanity). You have two options:
PYTHONSTARTUPenvironment variable, which if pointing to the name of a readable file
the Python commands in that file are executed before the first prompt is displayed in interactive mode.
python -i [script], which will cause the interpreter to remain in interactive mode after evaluating the script specified on the command line. You can use it in combination with an
Start by saving those two lines to a file. I’ll call mine
PYTHONSTARTUP route sets this environment variable in your personal initialization file,
.bashrc for the bashful of us (why you want
bashrc instead of
alias route defines an alias in your personal initialization file for
python -i ~/.python_init.py:
Now you can start your python interpreter using 50% fewer characters!:
Either works the same, but I would think that
PYTHONSTARTUP, being a set and forget option, would serve you better.
Want to know more? Read the rlcompleter documentation. The readline docs are interesting, too.