msg289342 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2017-03-10 08:10 |
$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: if sys.version_info < (3,): try: import readline, os, atexit histfile = os.path.join(os.path.expanduser("~"), ".python2_history") try: readline.read_history_file(histfile) except IOError: pass atexit.register(readline.write_history_file, histfile) del os, histfile except ImportError: pass |
|
|
msg289402 - (view) |
Author: Barry A. Warsaw (barry) *  |
Date: 2017-03-10 18:57 |
I don't think the Python envar has to follow the contraction from bash. PYTHONHISTORYreadsverynicely.IhavesimilarcodeinmyPYTHONHISTORY reads very nicely. I have similar code in my PYTHONHISTORYreadsverynicely.IhavesimilarcodeinmyPYTHONSTARTUP, but it would be nice to be able to get rid of it and just let Python do the common thing. |
|
|
msg289497 - (view) |
Author: (yan12125) * |
Date: 2017-03-12 11:42 |
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? By the way, seems comments starting from https://github.com/python/cpython/pull/473/files#diff-f34a16518c608b2ca946d3f5ca0a1942R419 should be updated too. |
|
|
msg289624 - (view) |
Author: Barry A. Warsaw (barry) *  |
Date: 2017-03-14 22:05 |
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. |
|
|
msg343375 - (view) |
Author: Zackery Spytz (ZackerySpytz) *  |
Date: 2019-05-24 11:34 |
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. |
|
|