home *** CD-ROM | disk | FTP | other *** search
/ chilidog.highland.cc.ks.us / chilidog.highland.cc.ks.us.zip / chilidog.highland.cc.ks.us / backup / bradford.20110725.etc.tar.gz / bradford.20110725.etc.tar / etc / pythonstart < prev    next >
Text File  |  2006-10-13  |  697b  |  30 lines

  1. # startup script for python to enable saving of interpreter history and
  2. # enabling name completion
  3.  
  4. # import needed modules
  5. import atexit
  6. import os
  7. import readline
  8. import rlcompleter
  9.  
  10. # where is history saved
  11. historyPath = os.path.expanduser("~/.pyhistory")
  12.  
  13. # handler for saving history
  14. def save_history(historyPath=historyPath):
  15.     import readline
  16.     readline.write_history_file(historyPath)
  17.  
  18. # read history, if it exists
  19. if os.path.exists(historyPath):
  20.     readline.read_history_file(historyPath)
  21.  
  22. # register saving handler
  23. atexit.register(save_history)
  24.  
  25. # enable completion
  26. readline.parse_and_bind('tab: complete')
  27.  
  28. # cleanup
  29. del os, atexit, readline, rlcompleter, save_history, historyPath
  30.