Many times, we use Python without having to write a program, some uncomplicated tasks, and I prefer to enter a few lines of code in IDLE (that is, interactive cue mode). However, in this mode to edit the code, there are not convenient places, the most important thing is, can not use the tab automatic completion, can not remember the last input command (no way, who let us in the shell accustomed to it).
At this point, we can start the script directly using Python to solve this problem.
The program that starts the script is very simple, here is not a lot of instructions, just give the code:
Import readline
import rlcompleter
import atexit
import OS
# tab AutoComplete
Readline.parse_and _bind (' Tab:complete ')
# history file
histfile = os.path.join (os.environ[' home '], '. Pythonhistory ')
try:
readline.read_history_file (histfile)
except IOError:
pass
atexit.register (readline.write_ History_file, Histfile)
When we're done, we'll save it as. Pythonstartup, store it in our own directory (for example,/home/yurii), and then point the Pythonstartup variable to the address you just put. The easiest way to do this is to add one line to the BASHRC:
Copy Code code as follows:
Export Pythonstartup=/home/yurii/.pythonstartup
In this way, not only increased the tab automatically complement the full function, and restart the idle, through the key, but also turn to the last input command, very convenient.