comparison .python/startup.py @ 0:c30d68fbd368

Initial import from svn.
author Augie Fackler <durin42@gmail.com>
date Wed, 26 Nov 2008 10:56:09 -0600
parents
children 5f523100226f
comparison
equal deleted inserted replaced
-1:000000000000 0:c30d68fbd368
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=/max/home/itamar/.pystartup" in bash.
7 #
8 # Note that PYTHONSTARTUP does *not* expand "~", so you have to put in the
9 # full path to your home directory.
10
11 import atexit
12 import os
13 import readline
14 import rlcompleter
15
16 # TODO(augie) I'd like to replace this with an environment variable
17 historyPath = os.path.expanduser("~/.python/python_history")
18
19 def save_history(historyPath=historyPath):
20 import readline
21 readline.write_history_file(historyPath)
22
23 if os.path.exists(historyPath):
24 readline.read_history_file(historyPath)
25
26 atexit.register(save_history)
27
28 # Clean up after ourselves so we don't pollute the namespace
29 del os, atexit, readline, rlcompleter, save_history, historyPath
30 try:
31 import IPython
32 def ipy():
33 IPython.Shell.start().mainloop()
34 except ImportError:
35 pass