Permalink
Browse files

Improve history reading

  • Loading branch information...
1 parent 21ee229 commit 3fe3452c23b415304032e4d29ae8a320b25af489 @dcramer committed Apr 19, 2013
Showing with 5 additions and 9 deletions.
  1. +5 −9 python/pythonrc.py
View
14 python/pythonrc.py
@@ -5,20 +5,16 @@
import atexit
import os
import readline
-import rlcompleter
readline.parse_and_bind('tab: complete')
history = os.path.expanduser("~/.pythonhist")
-def save_history(history=history):
- import readline
- readline.write_history_file(history)
-
if os.path.exists(history):
try:
readline.read_history_file(history)
- except IOError:
- pass
+ except IOError, e:
+ print "Failed to read %r: %s" % (history, e)
+
+readline.set_history_length(1024 * 5)
-atexit.register(save_history)
-del os, atexit, readline, rlcompleter, save_history, history
+atexit.register(lambda x=history: readline.write_history_file(x))

0 comments on commit 3fe3452

Please sign in to comment.