Python aliases under Windows?

Paul Moore p.f.moore at gmail.com
Tue Apr 3 09:45:56 EDT 2018


On 3 April 2018 at 10:24, Kirill Balunov <kirillbalunov at gmail.com> wrote:
> Perhaps this is a silly question but still...There is PEP 394 "The "python"
> Command on Unix-Like Systems" which I find very reasonable, no matter how
> it is respected. Why was not _somewhat_ the same done for Windows?

History, mainly. Plus the fact that the Unix convention is *not* that
reasonable. Why should a system with only Python 3 installed (very
common on Windows) not use "python" for that interpreter? The
requirement that "python" must always refer to Python 2 comes from
historical constraints on how Linux distributions chose to write their
system scripts, AIUI.

But debating why things are the way they are isn't that productive.
It's the reality, so we need to deal with it.

> p.s.: I know there is a `py` launcher under Windows, but is does not help
> in this situation.

Could you not use an alias?

In [1]: import sys
   ...: if sys.platform.startswith('win'):
   ...:     %alias python3 py -3
   ...: else:
   ...:     %alias python3 python3
   ...:
   ...: ver = %python3 --version
   ...: ver
   ...:
Python 3.6.2

Paul



More information about the Python-list mailing list