[Python-ideas] Make py.exe default to Python 3

Paul Moore p.f.moore at gmail.com
Tue Mar 8 04:24:39 EST 2016


The "py.exe" wrapper on Windows runs the latest Python version
available on the user's PC, but it prefers Python 2 if the user has
both Python 2 and 3 installed. With Python 3.5 being released, is it
not about time that we switched that default to always prefer the
latest version available?

For scripts, users can always specify a shebang line, exactly as on
Unix. For interactive use, people who prefer Python 2 simply have to
create a py.ini file saying

[defaults]
python=2

At the moment, someone using Python 3 exclusively can use "py" to
start the Python interpreter - and with the changes in the Python 3.5
installer, defaulting to a per-user install that's not on PATH, this
is often the most convenient approach. But if that person installs
Python 2 (say, to test some code on that version) py.exe silently
switches to using Python 2. And it does so regardless of whether you
specify "make this the default Python" in the installer.

It seems to me that this behaviour is much more unexpected than the
equivalent of a Python user installing Python 3 (py.exe switches to
Python 3, but that's "obviously" the latest version).

So I suggest that in Python 3.6, we (finally) switch py.exe to run the
latest version of Python on the user's machine *regardless of the
major version*.

This will be a compatibility break, but arguably no more serious than
the fact that if the user installs Python 3.6 and puts it on PATH,
then "python.exe" now points to Python 3.6. To cover people just
installing Python 3.6 for testing, we could check in the installer and
if the user only currently has Python 2 installed, has no py.ini, and
doesn't select "make this my default Python" for Python 3.6, then we
write a py.ini defaulting to Python 2. I don't know if that's worth
the effort, it depends largely on how many people will be affected by
the change.

Paul


More information about the Python-ideas mailing list