Christopher Barker wrote:
I think it’s a “Bad Idea” to use an environment variable — who knows what Python script may be running on a given system? But a standard command line argument to the interpreter could be useful.
Can you clarify what the concern is about other Python scripts running? Why doesn't that apply to [all the other special PYTHON* environment variables](https://docs.python.org/3/using/cmdline.html#environment-variables), such as `PYTHONWARNINGS` or `PYTHONVERBOSE`?
Command line arguments only work if you're invoking the `python` command directly. If you're running something above that like a bash script or a package entrypoint it's more complicated. And configuring environment variables is sometimes easier than changing a command or editing a script, like when you're configuring a service hosted in the cloud (personally I'm thinking of AWS ECS).
I say do the same thing as so many other options and offer both a command line argument and an environment variable. I don't think many people will be setting the environment variable in their global shell profiles. When I want to set PYTHONPATH I usually write:
PYTHONPATH=/some/path python script.py
which has no chance to affect anything else.