admin管理员组

文章数量:1310415

The python3 REPL on macos ventura (chip m1) store the interactive shell history one file per session. At the end of the week I found myself with many hidden files in $HOME: one .python_history, dozens of .python_history-12345.tmp, where 12345 can be any sequence of 5 digits.

Here the exact sequence of operations:

$ rm .python_history*
$ python3
Python 3.10.1 (main, May  2 2022, 14:56:30) [Clang 13.1.6 (clang-1316.0.21.2.3)] on darwin
>>> x = 5
>>> quit()
$ python3
>>> y = 44
>>> quit()
$ ls .python_history*
.python_history           .python_history-57028.tmp

The content of .python_history is always the log of the first session. The content of the other is the concatenation of the original one and the last session.

Looking for solutions I found many suggestions like this one which has for goal to disable the history.

I don't want that.

Is there a way to force different sessions to continue appending to the original log file?

本文标签: pythonMultiple pythonhistory filesStack Overflow