blob: 9ab457e98b02a34813f897bcf347236d7107a206 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import os
import atexit
import readline
state_home = os.environ.get("XDG_STATE_HOME")
if state_home is None:
state_home = os.path.join(os.path.expanduser('~'), ".local", "state")
history = os.path.join(state_home, "python_history")
try:
readline.read_history_file(history)
except OSError:
pass
def write_history():
try:
readline.write_history_file(history)
except OSError:
pass
atexit.register(write_history)
|