]>
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 default_completer
= rlcompleter
.Completer()
38 history_path
= os
.path
.expanduser("~/.python_history")
40 def my_completer(text
, state
):
41 if text
.strip() == "":
47 return default_completer
.complete(text
, state
)
49 def save_history(history_path
=history_path
):
51 readline
.write_history_file(history_path
)
53 readline
.set_completer(my_completer
)
54 readline
.parse_and_bind("tab: complete")
56 if os
.path
.exists(history_path
):
57 readline
.read_history_file(history_path
)
59 atexit
.register(save_history
)
61 del rlcompleter
, readline
, atexit