Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. # Add auto-completion and a stored history file of commands to your Python
  2. # interactive interpreter. Requires Python 2.0+, readline. Autocomplete is
  3. # bound to the Esc key by default (you can change it - see readline docs).
  4. #
  5. # Store the file in ~/.pystartup, and set an environment variable to point
  6. # to it: "export PYTHONSTARTUP=~/.pystartup" in bash.
  7.  
  8. import atexit
  9. import os
  10. import readline
  11. import rlcompleter
  12.  
  13. historyPath = os.path.expanduser("~/.pyhistory")
  14.  
  15. def save_history(historyPath=historyPath):
  16. import readline
  17. readline.write_history_file(historyPath)
  18.  
  19. if os.path.exists(historyPath):
  20. readline.read_history_file(historyPath)
  21.  
  22. atexit.register(save_history)
  23. del os, atexit, readline, rlcompleter, save_history, historyPath
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement