Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
python [2006/06/09 00:00] a |
python [2009/05/25 00:35] (current) |
||
|---|---|---|---|
| Line 2: | Line 2: | ||
| see: **[[http:// | see: **[[http:// | ||
| + | |||
| ==== python interpreter (history + autocomplete) ==== | ==== python interpreter (history + autocomplete) ==== | ||
| **'' | **'' | ||
| - | | + | # startup script for python to enable saving of interpreter history and |
| - | import readline | + | |
| - | | + | |
| - | | + | # import needed modules |
| - | else: | + | |
| - | import | + | |
| - | readline.parse_and_bind("tab: complete" | + | import readline |
| - | | + | import rlcompleter |
| - | | + | |
| - | try: | + | # where is history saved |
| - | readline.read_history_file(histfile) | + | |
| - | | + | |
| - | pass | + | # handler for saving history |
| - | | + | def save_history(historyPath=historyPath): |
| - | | + | |
| - | + | | |
| + | | ||
| + | # read history, if it exists | ||
| + | | ||
| + | | ||
| + | | ||
| + | # register saving handler | ||
| + | | ||
| + | |||
| + | # enable completion | ||
| + | readline.parse_and_bind(' | ||
| + | | ||
| + | # cleanup | ||
| + | del os, atexit, readline, rlcompleter, | ||
| + | |||
| **'' | **'' | ||
| export PYTHONSTARTUP=~/ | export PYTHONSTARTUP=~/ | ||

