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
$HISTFILE is the name of the file in which Bash command history is saved. Shouldn't the name of similar environment variable for Python be PYTHONHISTFILE?
Bash uses several environment variables for control its command history: HISTCONTROL, HISTFILE, HISTFILESIZE, HISTIGNORE, HISTSIZE, HISTTIMEFORMAT. Does Python need corresponding environment variables?
Wouldn't be better to control all these details by Python code in .pythonrc.py rather than by environment variables? For example I have the following code in my .pythonrc.py:
I don't think the Python envar has to follow the contraction from bash. $PYTHONHISTORY reads very nicely.
I have similar code in my $PYTHONSTARTUP, but it would be nice to be able to get rid of it and just let Python do the common thing.
yan12125 commented on Mar 12, 2017
yan12125mannequin
Mannequin
More actions
That's a great feature! Here's a question: what should be CPython's behavior when PYTHONHISTORY is explicitly set to empty? Currently there's an error:
$ PYTHONHISTORY= ./python
Python 3.7.0a0 (master:f6595983e08fe20cf06a2535d74d912c6dbb044f, Mar 12 2017, 19:22:29)
[GCC 6.3.1 20170306] on linux
Type "help", "copyright", "credits" or "license"for more information.
>>>
Error in atexit._run_exitfuncs:
FileNotFoundError: [Errno 2] No such file or directory
Maybe it's better to just disable the history functionality in this case?
On Mar 12, 2017, at 11:42 AM, Chi Hsuan Yen wrote:
That's a great feature! Here's a question: what should be CPython's behavior
when PYTHONHISTORY is explicitly set to empty? Currently there's an error:
$ PYTHONHISTORY= ./python
Python 3.7.0a0 (master:f6595983e08fe20cf06a2535d74d912c6dbb044f, Mar 12 2017, 19:22:29)
[GCC 6.3.1 20170306] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
Error in atexit._run_exitfuncs:
FileNotFoundError: [Errno 2] No such file or directory
Yeah, that's not good. I'll note that in the PR.
(But also note that you have to unset PYTHONSTARTUP if you, like me, use that
as the old school way of enabling history.)
Maybe it's better to just disable the history functionality in this case?
It should use the default, but it shouldn't cause an error.
PR 473 was closed by its author. I have created a new pull request (PR 13208) that addresses all of Berker Peksag's comments on the old PR. Please have a look.
Activity
serhiy-storchaka commentedon Mar 10, 2017
$HISTFILE is the name of the file in which Bash command history is saved. Shouldn't the name of similar environment variable for Python be PYTHONHISTFILE?
Bash uses several environment variables for control its command history: HISTCONTROL, HISTFILE, HISTFILESIZE, HISTIGNORE, HISTSIZE, HISTTIMEFORMAT. Does Python need corresponding environment variables?
Wouldn't be better to control all these details by Python code in .pythonrc.py rather than by environment variables? For example I have the following code in my .pythonrc.py:
warsaw commentedon Mar 10, 2017
I don't think the Python envar has to follow the contraction from bash. $PYTHONHISTORY reads very nicely.
I have similar code in my $PYTHONSTARTUP, but it would be nice to be able to get rid of it and just let Python do the common thing.
yan12125 commentedon Mar 12, 2017
That's a great feature! Here's a question: what should be CPython's behavior when PYTHONHISTORY is explicitly set to empty? Currently there's an error:
Maybe it's better to just disable the history functionality in this case?
By the way, seems comments starting from https://github.com/python/cpython/pull/473/files#diff-f34a16518c608b2ca946d3f5ca0a1942R419 should be updated too.
warsaw commentedon Mar 14, 2017
On Mar 12, 2017, at 11:42 AM, Chi Hsuan Yen wrote:
Yeah, that's not good. I'll note that in the PR.
(But also note that you have to unset PYTHONSTARTUP if you, like me, use that
as the old school way of enabling history.)
It should use the default, but it shouldn't cause an error.
ZackerySpytz commentedon May 24, 2019
PR 473 was closed by its author. I have created a new pull request (PR 13208) that addresses all of Berker Peksag's comments on the old PR. Please have a look.
[-]New environment variable PYTHONHISTORY[/-][+]New environment variable PYTHON_HISTORY[/+]Merge remote-tracking branch 'upstream/main' into pythongh-73965-PYTH…
gh-73965: New environment variable PYTHON_HISTORY (#13208)
gh-73965: Move PYTHON_HISTORY into the correct usage section (#113798)
pythongh-73965: New environment variable PYTHON_HISTORY (python#13208)
pythongh-73965: Move PYTHON_HISTORY into the correct usage section (p…
pythongh-73965: New environment variable PYTHON_HISTORY (python#13208)
pythongh-73965: Move PYTHON_HISTORY into the correct usage section (p…
pythongh-73965: New environment variable PYTHON_HISTORY (python#13208)
pythongh-73965: Move PYTHON_HISTORY into the correct usage section (p…