nix

configuration files that power my machines
Log | Files | Refs | README | LICENSE

pythonrc (746B)


      1 #!/usr/bin/env python
      2 
      3 def _setup_readline():
      4     import atexit
      5     import os
      6     import readline
      7     import rlcompleter
      8 
      9     history_path = os.path.expanduser("~/.python_history")
     10 
     11     if not os.path.exists(history_path) and not os.path.isdir(history_path):
     12         try:
     13             open(history_path, 'w').close()
     14         except IOError:
     15             pass
     16 
     17     if os.access(history_path, os.W_OK):
     18         atexit.register(lambda x=history_path: readline.write_history_file(x))
     19 
     20     if os.access(history_path, os.R_OK):
     21         readline.read_history_file(history_path)
     22 
     23     readline.parse_and_bind("tab: complete")
     24     readline.set_history_length(100000)
     25 
     26 _setup_readline()
     27 
     28 # Default imports
     29 from pprint import pprint as pp
     30 import os
     31 import sys