GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-73965: New environment variable PYTHON_HISTORY by ZackerySpytz · Pull Request #13208 · python/cpython

Conversation

@ZackerySpytz

@ZackerySpytz ZackerySpytz commented May 8, 2019 •
edited by hugovk
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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

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

  • Issue: New environment variable PYTHON_HISTORY #73965

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vszakats, MestreLion, EmilRehnberg, NilsIrl, rafi, agostonbarna, coldfix, septatrix, ZLima12, carlsmedstad, and 34 more reacted with thumbs up emoji erikw and Lanjelin reacted with hooray emoji erikw reacted with eyes emoji
All reactions
  • 👍 44 reactions
  • 🎉 2 reactions
  • 👀 1 reaction
@ZackerySpytz Levi Sabah
bpo-29779: New environment variable PYTHONHISTORY
a2ca22c
It can be used to set the location of a .python_history file.

Co-Authored-By: Levi Sabah <[email protected]>
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label May 8, 2019
@bedevere-bot bedevere-bot added the awaiting review label May 8, 2019
pablogsal
pablogsal reviewed May 10, 2019
View reviewed changes
Comment thread Doc/using/cmdline.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

pablogsal
pablogsal reviewed May 10, 2019
View reviewed changes
Comment thread Lib/site.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

pablogsal
pablogsal reviewed May 10, 2019
View reviewed changes
Comment thread Lib/site.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

pablogsal
pablogsal reviewed May 10, 2019
View reviewed changes
Comment thread 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).

@pablogsal pablogsal May 10, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@ZackerySpytz ZackerySpytz May 14, 2019

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

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...

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@eabase eabase Jan 25, 2022

Copy link
Copy Markdown

There was a problem hiding this comment.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tirkarthi

tirkarthi commented May 11, 2019

Copy link
Copy Markdown
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
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ZackerySpytz

ZackerySpytz commented May 14, 2019

Copy link
Copy Markdown
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.

pgilad reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ZackerySpytz
Address the review comments.
d13fd90
@ZackerySpytz

ZackerySpytz commented May 15, 2019

Copy link
Copy Markdown
Contributor Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ZackerySpytz ZackerySpytz mentioned this pull request May 15, 2019
bpo-29779: new environment variable PYTHONHISTORY. #473
Closed
tiran
tiran previously requested changes May 15, 2019
View reviewed changes

@tiran tiran left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting changes and removed awaiting review labels May 15, 2019
@bedevere-bot

bedevere-bot commented May 15, 2019

Copy link
Copy Markdown

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tiran

tiran commented May 15, 2019

Copy link
Copy Markdown
Member

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tiran
tiran reviewed May 15, 2019
View reviewed changes
Comment thread Lib/site.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

ZackerySpytz added 2 commits May 15, 2019 18:09
@ZackerySpytz
Account for sys.flags.ignore_environment.
9b7398c
@ZackerySpytz
Fix Travis.
fe6c760
@ZackerySpytz

ZackerySpytz commented May 19, 2019

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the awaiting changes label May 19, 2019
@bedevere-bot

bedevere-bot commented May 19, 2019

Copy link
Copy Markdown

Thanks for making the requested changes!

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot added the awaiting change review label May 19, 2019
@ZackerySpytz

ZackerySpytz commented May 19, 2019

Copy link
Copy Markdown
Contributor Author

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

Reword what?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ZackerySpytz
Merge remote-tracking branch 'upstream/master' into bpo-29779-PYTHONH…
4ddf85b
…ISTORY-env-var
@vszakats

vszakats commented Aug 28, 2019

Copy link
Copy Markdown

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.

MestreLion, Marcelotsvaz, and Fogapod reacted with thumbs up emoji
All reactions
  • 👍 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jonathan-conder jonathan-conder mentioned this pull request Nov 14, 2019
bpo-38791: Add readline history environment variable #17149
Closed
@EmilRehnberg

EmilRehnberg commented Dec 30, 2019

Copy link
Copy Markdown

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.

agostonbarna, wren, JoseFilipeFerreira, BachoSeven, hyperupcall, nash-pillai, and Fogapod reacted with thumbs up emoji
All reactions
  • 👍 7 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@wren

wren commented Jul 4, 2020

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@eabase

eabase commented Jan 24, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

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.'
ammgws, Marcelotsvaz, sant0s12, Fogapod, roadkell, johndrinkwater, dryya, adhiraj2001, crahan, and ValdezFOmar reacted with thumbs up emoji
All reactions
  • 👍 10 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Jan 24, 2022
gh-88405: Use platform defined data directories instead of ~/.python_history #26377
Open
2 different history filenames, which is right?- Probably neither pyreadline3/pyreadline3#4
Open
@lucas-mior

This comment was marked as abuse.

Sign in to view
@ezio-melotti ezio-melotti removed the CLA signed label Jul 13, 2022
@njhanley njhanley mentioned this pull request Mar 5, 2023
Add environment variable to change REPL history file path denoland/deno#18010
Closed
hugovk
hugovk reviewed Dec 26, 2023
View reviewed changes

@hugovk hugovk left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/using/cmdline.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/using/cmdline.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/whatsnew/3.8.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/site.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/site.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_site.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Misc/NEWS.d/next/Library/2019-05-08-13-14-11.bpo-29779.jg33dp.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Misc/python.man Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Python/initconfig.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@hugovk hugovk changed the title bpo-29779: New environment variable PYTHONHISTORY gh-73965: New environment variable PYTHON_HISTORY Dec 26, 2023
@0xl3vi 0xl3vi mannequin mentioned this pull request Apr 10, 2022
New environment variable PYTHON_HISTORY #73965
Closed
@serhiy-storchaka
serhiy-storchaka self-requested a review December 26, 2023 11:28
hugovk added 2 commits January 4, 2024 14:07
@hugovk
Merge remote-tracking branch 'upstream/main' into pythongh-73965-PYTH…
d49c0ff
…ON_HISTORY-env-var
@hugovk
Rename to PYTHON_HISTORY and target 3.13
bc5b771
@hugovk
hugovk dismissed tiran’s stale review January 4, 2024 14:05

Dismissed stale review

@bedevere-app bedevere-app Bot added awaiting review and removed awaiting change review labels Jan 4, 2024
@hugovk

hugovk commented Jan 4, 2024

Copy link
Copy Markdown
Member

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

veilm, BachoSeven, foxjaw, vszakats, i13e, gh640, and bryan-hoang reacted with heart emoji
All reactions
  • ❤️ 7 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

hauntsaninja
hauntsaninja approved these changes Jan 7, 2024
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Jan 7, 2024
@hauntsaninja

hauntsaninja commented Jan 7, 2024

Copy link
Copy Markdown
Contributor

Thanks Hugo!

hugovk reacted with rocket emoji
All reactions
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hauntsaninja
hauntsaninja merged commit f19b93f into python:main Jan 7, 2024
@bedevere-app bedevere-app Bot removed the awaiting merge label Jan 7, 2024
serhiy-storchaka
serhiy-storchaka reviewed Jan 7, 2024
View reviewed changes
Comment thread Python/initconfig.c
"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"

@serhiy-storchaka serhiy-storchaka Jan 7, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@hugovk hugovk Jan 7, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Jan 7, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

veilm reacted with eyes emoji
All reactions
  • 👀 1 reaction

@hugovk hugovk Jan 7, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@hugovk hugovk mentioned this pull request Jan 7, 2024
gh-73965: Move PYTHON_HISTORY into the correct usage section #113798
Merged
kulikjak pushed a commit to kulikjak/cpython that referenced this pull request Jan 22, 2024
@ZackerySpytz Levi Sabah
@hugovk @kulikjak
pythongh-73965: New environment variable PYTHON_HISTORY (python#13208)
e2c66de
It can be used to set the location of a .python_history file

---------

Co-authored-by: Levi Sabah <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
@ZackerySpytz Levi Sabah
@hugovk @aisk
pythongh-73965: New environment variable PYTHON_HISTORY (python#13208)
ec64a14
It can be used to set the location of a .python_history file

---------

Co-authored-by: Levi Sabah <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
@ZackerySpytz Levi Sabah
@hugovk @Glyphack
pythongh-73965: New environment variable PYTHON_HISTORY (python#13208)
2b9d6ec
It can be used to set the location of a .python_history file

---------

Co-authored-by: Levi Sabah <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>
rbutoi pushed a commit to rbutoi/dotfiles that referenced this pull request Nov 6, 2024
@cardlytics-ghcr
PYTHON_HISTORY [new in 3.13](python/cpython#13208)
7310ae2
thanks to
https://unix.stackexchange.com/questions/630642/change-location-of-python-history
- don't use a new folder cause 1) no need for just 1 file 2) python won't make
it for you, will just fail to write
history. [`xdg-ninja`](https://github.com/b3nj5m1n/xdg-ninja) is good, we need
more all-in-one places for doing config like this. but it's more or less just a
community thing

will need a place for these lines in zshrc /shrug

+ try some LSP servers
+ bat hard-wraps, less -S is nice
rbutoi added a commit to rbutoi/dotfiles that referenced this pull request Jan 28, 2026
@rbutoi
PYTHON_HISTORY [new in 3.13](python/cpython#13208)
20d93ce
thanks to
https://unix.stackexchange.com/questions/630642/change-location-of-python-history
- don't use a new folder cause 1) no need for just 1 file 2) python won't make
it for you, will just fail to write
history. [`xdg-ninja`](https://github.com/b3nj5m1n/xdg-ninja) is good, we need
more all-in-one places for doing config like this. but it's more or less just a
community thing

will need a place for these lines in zshrc /shrug

+ try some LSP servers
+ bat hard-wraps, less -S is nice
@gaogaotiantian gaogaotiantian mentioned this pull request Oct 20, 2026
gh-141295: Persist pdb command history with PyREPL #159969
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@hugovk hugovk hugovk left review comments
@serhiy-storchaka serhiy-storchaka serhiy-storchaka left review comments
@pablogsal pablogsal pablogsal left review comments
@hauntsaninja hauntsaninja hauntsaninja approved these changes
+2 more reviewers
@tiran tiran tiran left review comments
@eabase eabase eabase left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

18 participants

@ZackerySpytz @tirkarthi @bedevere-bot @tiran @vszakats @EmilRehnberg @wren @ZLima12 @nash-pillai @i2 @warsaw @eabase @lucas-mior @hugovk @hauntsaninja @serhiy-storchaka @pablogsal @the-knights-who-say-ni
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.