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
{{ message }}
Repository navigation
Prefer "python" over "python3" for command line examples in docs. #98763
In particular, it's pretty strange that the argparse reference doc uses python very consistently, while the argparse HOWTO uses python3 very consistently.
Homebrew still installs and links python as python3. Ubuntu 20.04 LTS (at least via Windows Subsystem for Linux) does not have a python binary, but instead has python3. So, I think the issue is that until the OS distros start consistently installing python3.x interpreters as python in $PATH, we will have this issue. I think this means maybe everything needs to be explicitly python3 until that happens? Until we then have to change it back?
The referenced PEP says
The python command should always invoke Python 2 (to prevent hard-to-diagnose errors when Python 2 code is run on Python 3).
Which argues that it should be python3 - although that's not to say things haven't changed since the PEP was written.
On my Mac, python no longer refers to an executable. Only python3 works. So, at least for Mac Users, the status quo is better. With the proposed substitutions, the examples won't work any more.
On my Mac, python no longer refers to an executable. Only python3 works. So, at least for Mac Users, the status quo is better. With the proposed substitutions, the examples won't work any more.
On my Windows machine, only python works. python3 takes me to a page on the Windows Store inviting me to download Python (I obviously have it downloaded, but downloaded it from python.org instead of the Windows Store).
I think it's unlikely that there's anything that works for everybody, sadly.
The ideal future is that python works for everyone. I think it's just a question of how long we have to wait for Python 2 to sink into irrelevancy, before we can update PEP 394 to clearly recommend that redistributors should make python be Python 3, and also do things like #102358
In the meantime, we seem to be in a situation where there is no form we can use in the docs that will reliably work for all users, and I have no idea how we should handle that. It seems unlikely that "continue indefinitely to be randomly inconsistent depending who happened to write which docs" is the best option, though.
FWIW, #102354 is a bug recently filed by a Windows user about the doc examples using python3 not working for them. When I asked other core devs about this, I was pointed to #98761, which seemed to establish a clear consensus that we should prefer python over python3. I didn't see that there had been further discussion here. So I just merged #102696 which converts the last few python3 to python. So the status quo is now that we consistently use python. But we can leave this issue open to discuss how else we might want to handle it.
In the meantime, we seem to be in a situation where there is no form we can use in the docs that will reliably work for all users, ..
Unfortunately, that's true.
For me, this recommendation from PEP 394 is the most important:
While far from being universally available, python remains the preferred spelling for explicitly invoking Python, as this is the spelling that virtual environments make consistently available across different platforms and Python installations.
So for example in Django docs, we assume that command lines examples are run in virtual environments.
Reacted by Carl Meyer, Alex Waygood and Erlend E. Aasland
this is the spelling that virtual environments make consistently available
Which makes a lot of sense, but doesn't help resolve the question of which spelling the venv docs themselves should use :) Though I think at that point, "just be consistent with the rest of the docs" is a reasonable argument.
Reacted by Mariusz Felisiak, Alex Waygood and Erlend E. Aasland
Activity
pythongh-98763: Prefer "python" over "python3" for command line examp…
AlexWaygood commentedon Oct 27, 2022
I agree it would be nice to be more consistent here.
Here's the results of `git grep "$ python"` in the `Doc/` directory:
Here's the results of `git grep "$ python3"` in the `Doc/` directory:
In particular, it's pretty strange that the
argparsereference doc usespythonvery consistently, while theargparseHOWTO usespython3very consistently.sc68cal commentedon Nov 20, 2022
Homebrew still installs and links python as
python3. Ubuntu 20.04 LTS (at least via Windows Subsystem for Linux) does not have apythonbinary, but instead haspython3. So, I think the issue is that until the OS distros start consistently installing python3.x interpreters aspythonin $PATH, we will have this issue. I think this means maybe everything needs to be explicitlypython3until that happens? Until we then have to change it back?The referenced PEP says
Which argues that it should be
python3- although that's not to say things haven't changed since the PEP was written.AlexWaygood commentedon Nov 20, 2022
I'm removing the "easy" label since we already have a PR here, it just needs to be reviewed :)
pythongh-98763: Prefer "python" over "python3" for command line examp…
pythongh-98763: Prefer "python" over "python3" for command line examp…
gh-98763: Prefer "python" over "python3" for command line examples in…
hugovk commentedon Jan 12, 2023
See issue #100972 and PR #100973 for more.
rhettinger commentedon Jan 14, 2023
On my Mac, python no longer refers to an executable. Only python3 works. So, at least for Mac Users, the status quo is better. With the proposed substitutions, the examples won't work any more.
AlexWaygood commentedon Jan 14, 2023
On my Windows machine, only
pythonworks.python3takes me to a page on the Windows Store inviting me to download Python (I obviously have it downloaded, but downloaded it from python.org instead of the Windows Store).I think it's unlikely that there's anything that works for everybody, sadly.
carljm commentedon Mar 14, 2023
The ideal future is that
pythonworks for everyone. I think it's just a question of how long we have to wait for Python 2 to sink into irrelevancy, before we can update PEP 394 to clearly recommend that redistributors should makepythonbe Python 3, and also do things like #102358In the meantime, we seem to be in a situation where there is no form we can use in the docs that will reliably work for all users, and I have no idea how we should handle that. It seems unlikely that "continue indefinitely to be randomly inconsistent depending who happened to write which docs" is the best option, though.
carljm commentedon Mar 14, 2023
FWIW, #102354 is a bug recently filed by a Windows user about the doc examples using
python3not working for them. When I asked other core devs about this, I was pointed to #98761, which seemed to establish a clear consensus that we should preferpythonoverpython3. I didn't see that there had been further discussion here. So I just merged #102696 which converts the last fewpython3topython. So the status quo is now that we consistently usepython. But we can leave this issue open to discuss how else we might want to handle it.felixxm commentedon Mar 14, 2023
Unfortunately, that's true.
For me, this recommendation from PEP 394 is the most important:
So for example in Django docs, we assume that command lines examples are run in virtual environments.
carljm commentedon Mar 14, 2023
Which makes a lot of sense, but doesn't help resolve the question of which spelling the venv docs themselves should use :) Though I think at that point, "just be consistent with the rest of the docs" is a reasonable argument.
erlend-aasland commentedon Jun 19, 2023
The linked PR was merged. It seems to me we can close this. Please re-open if you feel more work is needed.
python/cpython#98763: Prefer "python" over "python3" for command line…
python/cpython#98763: Prefer "python" over "python3" for command line…
python/cpython#98763: Prefer "python" over "python3" for command line…