Skip to content

Conversation

@ZackerySpytz
Copy link
Contributor

@ZackerySpytz ZackerySpytz commented May 8, 2019

It can be used to set the location of a .python_history file.

Co-Authored-By: Levi Sabah [email protected]

It can be used to set the location of a .python_history file.

Co-Authored-By: Levi Sabah <[email protected]>
Misc/python.man Outdated
can be set to the callable of your debugger of choice.
.IP PYTHONHISTORY
This environment variable can be used to set the location of a history file
(it is \fI~/.python_history\fP by default).
Copy link
Member

@pablogsal pablogsal May 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add the windows default as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be frank, I'm not sure if the Windows default should be mentioned in the man page...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is nothing wrong with mentioning Windows ops in man pages.

@tirkarthi
Copy link
Member

There are few other places in Docs where hardcoded value of ~/.python_history is referred to.

$ rg python_history Doc
Doc/tutorial/interactive.rst
28:history into a file named :file:`.python_history` in your user directory.

Doc/library/readline.rst
292:file named :file:`.python_history` from the user's home directory.  The code
300:   histfile = os.path.join(os.path.expanduser("~"), ".python_history")
319:   histfile = os.path.join(os.path.expanduser("~"), ".python_history")

Doc/library/site.rst
135::file:`~/.python_history` as the history save file.  To disable it, delete (or

@ZackerySpytz
Copy link
Contributor Author

@tirkarthi The first three cases mention .python_history, not ~/.python_history, no?

The fourth case mentions ~/.python_history in the context of the readline
module, which is not available on Windows. So, I'm not sure if those parts of
the docs need to be modified.

@ZackerySpytz
Copy link
Contributor Author

By the way, on Windows, os.path.expanduser("~") returns (for example) 'C:\\Users\\Tim'.

tiran
tiran previously requested changes May 15, 2019
Copy link
Member

@tiran tiran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new env var does not obey the sys.flags.ignore_environment flag. Please add a test that the new env var is ignored with -E or -I mode.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@tiran
Copy link
Member

tiran commented May 15, 2019

Could you please reword to explain what the history file actually does? It's non-obvious to users that are not familiar with readline module internals.

@ZackerySpytz
Copy link
Contributor Author

I have made the requested changes; please review again.

@bedevere-bot
Copy link

Thanks for making the requested changes!

@tiran: please review the changes made to this pull request.

@ZackerySpytz
Copy link
Contributor Author

Could you please reword to explain what the history file actually does?

Reword what?

@vszakats
Copy link

Can this be merged? It seems fairly obvious what .python_history means and it'd be quite nice to be able to control where it goes.

@EmilRehnberg
Copy link

Thanks for this!

Please make sure there will be no problem with paths with subdirectories that might not be created. E.g. "export PYTHONHISTORY=$HOME/.cache/python/history please assert that the path will be created if missing.

@wren
Copy link

wren commented Jul 4, 2020

Any way to help get this through? It looks like it's been ready for a while.

@warsaw
Copy link
Member

warsaw commented Oct 22, 2021

Looks like there are conflicts now which need to be resolved, and probably rebased.

@eabase
Copy link

eabase commented Jan 24, 2022

Guys, why on earth are you hard-coding a commonly used and often changed file-path like this?

I was sincerely expecting to find an internal built-in variable named something like DEFAULT_HISTORY_FILE, but to my unpleasant surprise, I instead find history = os.path.join(os.path.expanduser('~'),'.python_history').

While at the same time being met with:

readline.write_history_file.__doc__
# 'Save a readline history file. The default filename is ~/.history.'

@lucas-mior

This comment was marked as abuse.

Copy link
Member

@hugovk hugovk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please resolve the merge conflicts.

@hugovk hugovk changed the title bpo-29779: New environment variable PYTHONHISTORY gh-73965: New environment variable PYTHON_HISTORY Dec 26, 2023
@serhiy-storchaka serhiy-storchaka self-requested a review December 26, 2023 11:28
@hugovk
Copy link
Member

hugovk commented Jan 4, 2024

I've resolved conflicts, renamed to PYTHON_HISTORY and targeted 3.13.

@hauntsaninja
Copy link
Contributor

Thanks Hugo!

@hauntsaninja hauntsaninja merged commit f19b93f into python:main Jan 7, 2024
"PYTHON_COLORS : If this variable is set to 1, the interpreter will"
" colorize various kinds of output. Setting it to 0 deactivates this behavior.\n"
"These variables have equivalent command-line parameters (see --help for details):\n"
"PYTHON_HISTORY: the location of a .python_history file.\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What command line parameter sets it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't have one, I compared with PYTHON_COLORS which doesn't either (#112732). Should we add one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it doesn't have one, then it is in the wrong section.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, please see PR #113798 to move it to the correct section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.