]>
code.delx.au - dotfiles/blob - .pythonrc.py
fe74d41bffb56813bd9ba094366e873e0bd4365e
3 from __future__
import division
7 ####################################
8 # Python2 compatibility for urllib #
9 ####################################
16 class dummy_urllib_module
:
19 sys
.modules
["urllib"] = dummy_urllib_module
20 sys
.modules
["urllib.parse"] = dummy_urllib_module
.parse
21 sys
.modules
["urllib.request"] = dummy_urllib_module
.request
22 dummy_urllib_module
.parse
.urlencode
= urllib
.urlencode
53 #######################
54 # Readline completion #
55 #######################
57 def setup_readline_completion():
62 history_path
= os
.path
.expanduser("~/.python_history")
64 default_completer
= rlcompleter
.Completer()
66 readline
.parse_and_bind("tab: complete")
68 if os
.path
.exists(history_path
):
69 readline
.read_history_file(history_path
)
71 def my_completer(text
, state
):
72 if text
.strip() == "":
78 return default_completer
.complete(text
, state
)
79 readline
.set_completer(my_completer
)
81 def save_history(history_path
=history_path
):
82 readline
.write_history_file(history_path
)
83 atexit
.register(save_history
)
85 setup_readline_completion()