Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
python [2006/05/08 22:47] a created |
python [2009/05/25 00:35] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Python ====== | ====== Python ====== | ||
| - | ==== python | + | see: **[[http:// |
| - | **'' | ||
| - | try: | ||
| - | import readline | ||
| - | except ImportError: | ||
| - | print " | ||
| - | else: | ||
| - | import rlcompleter | ||
| - | readline.parse_and_bind(" | ||
| - | import os | ||
| - | histfile = os.path.join(os.environ[" | ||
| - | try: | ||
| - | readline.read_history_file(histfile) | ||
| - | except IOError: | ||
| - | pass | ||
| - | import atexit | ||
| - | atexit.register(readline.write_history_file, | ||
| + | ==== python interpreter (history + autocomplete) ==== | ||
| + | **'' | ||
| + | # startup script for python to enable saving of interpreter history and | ||
| + | # enabling name completion | ||
| + | |||
| + | # import needed modules | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | |||
| + | # where is history saved | ||
| + | | ||
| + | |||
| + | # handler for saving history | ||
| + | def save_history(historyPath=historyPath): | ||
| + | | ||
| + | | ||
| + | |||
| + | # read history, if it exists | ||
| + | if os.path.exists(historyPath): | ||
| + | | ||
| + | |||
| + | # register saving handler | ||
| + | | ||
| + | |||
| + | # enable completion | ||
| + | | ||
| + | |||
| + | # cleanup | ||
| + | del os, atexit, readline, rlcompleter, | ||
| + | |||
| **'' | **'' | ||
| export PYTHONSTARTUP=~/ | export PYTHONSTARTUP=~/ | ||

