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