]>
code.delx.au - dotfiles/blob - .pythonrc.py
3 # Useful things to have
4 from __future__
import division
13 from datetime
import datetime
, timedelta
26 # Not available in Python3
34 # Readline completion of everything :)
35 import rlcompleter
, readline
, atexit
36 defaultCompleter
= rlcompleter
.Completer()
38 historyPath
= os
.path
.expanduser("~/.pyhistory")
40 def myCompleter(text
, state
):
41 if text
.strip() == "":
47 return defaultCompleter
.complete(text
, state
)
49 def save_history(historyPath
=historyPath
):
51 readline
.write_history_file(historyPath
)
53 readline
.set_completer(myCompleter
)
54 readline
.parse_and_bind("tab: complete")
56 if os
.path
.exists(historyPath
):
57 readline
.read_history_file(historyPath
)
59 atexit
.register(save_history
)
61 del rlcompleter
, readline
, atexit