Extend Python's interactive mode

Creating a python startup

--Create a .python startup and put it in $ HOME

# -*- encoding: utf-8 -*-
# Python startup file
import readline
import rlcompleter
import atexit
import os
# tab complete
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)
del os, histfile, readline, rlcompleter, atexit

Path setting

export PYTHONSTARTUP=~/.pythonstartup
source ~/.zshrc

Recommended Posts

Extend Python's interactive mode
Asynchronously run matplotlib interactive mode
Enter interactive mode after script execution with Python's -i flag