Python aliases under Windows?

Kirill Balunov kirillbalunov at gmail.com
Tue Apr 3 11:00:28 EDT 2018


2018-04-03 16:45 GMT+03:00 Paul Moore <p.f.moore at gmail.com>:

> 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.
>

I understand that general rules are not possible among the various OSs. If
just `python` suits for Windows it is OK. But I have the same question, why
should a system with Python 3 installed not use both "python" and "python3"
for that interpreter? This `python3` will allow to slightly unify the
workflow on different OSs, while it will be done almost for free. I want to
add that there are plenty of tutorials which use `python3 ...` without
reference to UNIX world, why are these mental overhead with `python3` or
`py -3` necessary?

In fact, I do not really understand why the _py launcher_ way is easier or
better than `python3` or `python3.6` way even on Windows. There are already
`pip.exe`, `pip3.exe`, `pip3.6.exe` which solve the same problem,  but they
are all redundant, when it is better to use `python3.6 -m pip ... ` or
currently `py -3.6 -m pip install ...`.

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


Thank you this works for me!

With kind regards,
-gdg



More information about the Python-list mailing list