]>
code.delx.au - dotfiles/blob - .pythonrc.py
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
52 import tomli
as tomllib
63 #######################
64 # Readline completion #
65 #######################
67 def setup_readline_completion():
72 history_path
= os
.path
.expanduser("~/.python_history")
74 default_completer
= rlcompleter
.Completer()
76 readline
.parse_and_bind("tab: complete")
78 if os
.path
.exists(history_path
):
79 readline
.read_history_file(history_path
)
81 def my_completer(text
, state
):
82 if text
.strip() == "":
88 return default_completer
.complete(text
, state
)
89 readline
.set_completer(my_completer
)
91 def save_history(history_path
=history_path
):
92 readline
.write_history_file(history_path
)
93 atexit
.register(save_history
)
95 setup_readline_completion()