]>
code.delx.au - dotfiles/blob - .pythonrc.py
3 # Useful things to have
4 from __future__
import division
6 import sys
, os
, re
, math
8 # Readline completion of everything :)
9 import rlcompleter
, readline
, atexit
10 defaultCompleter
= rlcompleter
.Completer()
12 historyPath
= os
.path
.expanduser("~/.pyhistory")
14 def myCompleter(text
, state
):
15 if text
.strip() == "" and state
== 0:
18 return defaultCompleter
.complete(text
, state
)
20 def save_history(historyPath
=historyPath
):
22 readline
.write_history_file(historyPath
)
24 readline
.set_completer(myCompleter
)
25 readline
.parse_and_bind("tab: complete")
27 if os
.path
.exists(historyPath
):
28 readline
.read_history_file(historyPath
)
30 atexit
.register(save_history
)
32 del rlcompleter
, readline
, atexit