Mercurial > public > dotfiles
changeset 14:357906c82c1f
Silently fail instead of traceback if executed on Windows.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 05 Jun 2013 20:08:58 -0500 |
parents | 0c225d280b06 |
children | 9b01ad28a5c3 |
files | python/.pythonstartup |
diffstat | 1 files changed, 23 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/python/.pythonstartup Tue Jun 04 19:25:17 2013 -0500 +++ b/python/.pythonstartup Wed Jun 05 20:08:58 2013 -0500 @@ -1,15 +1,23 @@ -# python startup file -import readline -import rlcompleter -import atexit -import os -# tab completion -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 +# python startup file +try: + import readline +except ImportError: + pass +else: + import atexit + import os + import rlcompleter + + # tab completion + 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 + readline.set_history_length(1024) + + atexit.register(readline.write_history_file, histfile) + del os, histfile, readline, rlcompleter