You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use platform defined data directories instead of ~/.python_history #88405
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2021-05-26.10:58:43.729>labels= ['type-feature', 'library', '3.11']
title='Use platform defined data directories instead of ~/.python_history'updated_at=<Date2021-05-26.11:39:53.868>user='https://github.com/oxalica'
Currently we use path ~/.python_history for history file in all platforms.
It is not a good choice since it spams in user's home directory.
There are already specifications for where to store program data.
For Windows, we should use %APPDATA%/Python/history;
for Mac OS, we should use ~/Library/Application Support/Python/history;
for other POSIX platforms, we should use $XDG_DATA_HOME/python/history or ~/.local/share/python/history according to XDG Spec.
These paths should be preferred as default. But we can also check and use ~/.python_history if it exists and readable, for compatibility.
for other POSIX platforms, we should use $XDG_DATA_HOME/python/history or ~/.local/share/python/history according to XDG Spec.
The specification actually received an amendment on the very month this message was originally posted. It now additionally specifies $XDG_STATE_HOME, which should be the way to go here instead of $XDG_DATA_HOME:
The $XDG_STATE_HOME contains state data that should persist between (application) restarts, but that is not important or portable enough to the user that it should be stored in $XDG_DATA_HOME. It may contain:
actions history (logs, history, recently used files, …)
current state of the application that can be reused on a restart (view, layout, open files, undo history, …)
Activity
oxalica commentedon May 26, 2021
Currently we use path
~/.python_historyfor history file in all platforms.It is not a good choice since it spams in user's home directory.
There are already specifications for where to store program data.
For Windows, we should use
%APPDATA%/Python/history;for Mac OS, we should use
~/Library/Application Support/Python/history;for other POSIX platforms, we should use
$XDG_DATA_HOME/python/historyor~/.local/share/python/historyaccording to XDG Spec.These paths should be preferred as default. But we can also check and use
~/.python_historyif it exists and readable, for compatibility.Ige-fi commentedon May 27, 2022
The specification actually received an amendment on the very month this message was originally posted. It now additionally specifies
$XDG_STATE_HOME, which should be the way to go here instead of$XDG_DATA_HOME:hauntsaninja commentedon Jan 7, 2024
Note that we merged #73965 , so the location of this file can now be controlled by
PYTHON_HISTORYreturnDanilo commentedon May 14, 2024
If this is ever to be merged, maybe you could add something about pdb's ~/.pdbrc file? ;)