This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: python should read ~/.pythonrc.py by default
Type: enhancement Stage: resolved
Components: Versions: Python 3.2
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: eric.araujo, giampaolo.rodola, lesmana
Priority: normal Keywords:

Created on 2010-06-06 17:56 by lesmana, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (5)
msg107197 - (view) Author: lesmana (lesmana) Date: 2010-06-06 17:56
if started as an interactive session python should check for and read ~/.pythonrc.py by default.

furthermore there should be two options added:
--rcfile filename
this will read filename instead of ~/.pythonrc
--norc
this will prevent reading ~/.pythonrc

(this is inspired by how bash handles initialization)

afterwards the variable PYTHONSTARTUP can be deprecated.

as far as i know, everything which can be done by the variable PYTHONSTARTUP can be done with the suggested method. the advantage of the suggested method is that it is "intuitive" in the sense that it is the way most other tools do it (bash for example).
msg107239 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-06-06 22:05
As stated in http://docs.python.org/library/user (found via http://docs.python.org/genindex-Symbols), this file is an older customization hook that is deprecated. I (not a Python core dev, just a user) personally prefer the environment variable: I set it once in my .bashrc and every interactive python invocation uses it. (I admit that I have to cheat and import another module in order to be compatible from 2.4 to 3.1, but it’s not a big hurdle). Recent changes to the interpreter have added more envvars (PYTHONIOENCODING, PYTHONDONTWRITEBYTECODE), so I don’t see people agreeing to the removal of the venerable PYTHONSTARTUP.

Your last argument can also be reverted: Everything that can be done via pythonrc can be done via PYTHONSTARTUP. The advantage of using an envvar is that it mirrors the behavior of a lot of programs: EDITOR, PAGER, MAILER, BROWSER, LESS, GPG_AGENT_INFO, SSH_AUTH_SOCK, GZIP, EMAIL, and so on. :-)

FTR, ignoring PYTHONSTARTUP can be done by unsetting the variable before launching python, or using python -E (which will ignore all envvars, not only this one).
msg107251 - (view) Author: lesmana (lesmana) Date: 2010-06-06 23:18
the .pythonrc.py file is not deprecated. only the user module is deprecated.

the problem i have with the PYTHONSTARTUP variable is that i find it is an unecessary intermediate step to set up an initialization file.

let me elaborate: every single time you want to use PYTHONSTARTUP in any meaningfull way you will ALSO have to set up the corresponding file somehwere. it makes no sense to set up PYTHONSTARTUP without the file. it also makes no sense to set up the file without PYTHONSTARTUP. so PYTHONSTARTUP needs the file and the file needs PYTHONSTARTUP.

that means the variable PYTHONSTARTUP has no added value. it is just an extra step, an extra source of error and possibly confusion. that is why i suggest to skip the variable and just load the file directly.

if you (or anyone else) can point out a use case which can be done with PYTHONSTARTUP but cannot be done with my suggested method, or a use case where using PYTHONSTARTUP is so much simpler than using my suggested method, then i say mark this as wontfix. i was not able to think of such a use case, but i might be missing something.

there is the argument that PYTHONSTARTUP allows the flexibility to point to files with other names. that can be easily achieved by setting up an alias in .bashrc (or respective initialization file for your favorite shell) like this: alias python="python --rcfile somefile". alternatively you can symlink .pythonrc.py to somefile.

the effort to set up such an alias or symlink is the same as setting up an environment variable. everyone else who is happy with the default name (the majority in my opinion) will have one step less to set up.

about the name .pythonrc.py: looking around the web i have the impression that many people set their PYTHONSTARTUP variable to point to .pythonrc.py. i think this is because they used to have the .pythonrc.py file loaded by the module user. after they saw that the module user is beeing deprecated they just point PYTHONSTARTUP to that file. other than that i find the name .pythonrc.py is a fitting name for an initialization file.

about the other tools you mentioned. i checked some of them and some other tools which use environment variables. they almost never use the variables to just dully point to a file, exceptions are variables which point to a resource shared with many other tools (the temp directory for example).
msg120754 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-08 15:26
> the .pythonrc.py file is not deprecated. only the user module is deprecated.

Which amounts to the same IMO.

> the problem i have with the PYTHONSTARTUP variable is that i find it
> is an unecessary intermediate step to set up an initialization file.

Okay, I see your point, even though I’m not convinced :)  I suggest you write to the python-ideas mailing list to gather feedback about this.
msg132188 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-03-26 00:11
In the absence of reply, I am rejecting this feature.  Please feel free to reopen if there is new data or consensus on python-ideas.
History
Date User Action Args
2022-04-11 14:57:01adminsetgithub: 53165
2011-03-26 00:11:32eric.araujosetstatus: open -> closed
resolution: rejected
messages: + msg132188

stage: resolved
2010-11-08 15:26:14eric.araujosetmessages: + msg120754
versions: + Python 3.2
2010-06-07 20:03:52giampaolo.rodolasetnosy: + giampaolo.rodola
2010-06-06 23:18:18lesmanasetmessages: + msg107251
2010-06-06 22:05:57eric.araujosetnosy: + eric.araujo
messages: + msg107239
2010-06-06 17:56:21lesmanacreate