Mercurial > dotfiles
annotate .python/startup.py @ 153:eb7cb3d25060
Merge
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Fri, 09 Oct 2009 21:50:40 -0400 |
parents | 5f523100226f |
children |
rev | line source |
---|---|
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=/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() | |
103
5f523100226f
Be more permissive if ipy() cannot be defined as in bpython.
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
34 except: |
0 | 35 pass |