Skip to content

Instantly share code, notes, and snippets.

Forked from benhodgson/
Created April 10, 2014 17:16
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ldong/10403538 to your computer and use it in GitHub Desktop.
Python Startup File (from
Add this file to ~/ to add history between sessions and
auto-completion via the ESC key to the interactive Python interpreter. After
adding this file, put something like the following line in your .bash_profile:
Requires a recent version of Python and the readline package, which you can
install from or with easy_install.
easy_install -U readline
def _pythonrc():
import atexit
import os
import readline
import rlcompleter
readline.parse_and_bind("tab: complete")
history = os.path.expanduser("~/.py_history")
if os.path.exists(history):
def write_history(history=history):
del _pythonrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment