Skip to content

Instantly share code, notes, and snippets.

@Ry4an
Created February 12, 2013 18:31
Show Gist options
  • Save Ry4an/4772069 to your computer and use it in GitHub Desktop.
Save Ry4an/4772069 to your computer and use it in GitHub Desktop.
For getting history in python REPL. Mostly cribbed from stackoverflow answers
import atexit
import os
import re
import readline
import rlcompleter
import socket
import _socket
import sys
import time
try:
from dramafever.episode.models import *
except:
pass
history = os.path.expanduser('~/.python_history')
readline.read_history_file(history)
if 'libedit' in readline.__doc__:
readline.parse_and_bind("bind ^I rl_complete")
else:
readline.parse_and_bind("tab: complete")
atexit.register(readline.write_history_file, history)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment