Python aliases under Windows?

Ian Kelly ian.g.kelly at gmail.com
Tue Apr 3 09:15:30 EDT 2018


On Tue, Apr 3, 2018 at 3:24 AM, 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?

PEP 394 is meant to provide standardization between distributions of
Linux which might make different choices about how to name the python
aliases. Windows doesn't have distributions, and PEP 397 was being
worked on at about the same time, so I suppose it wasn't considered
necessary. Also, Windows and Linux are different enough that
standardization between the two environments may not have been
considered a realistic goal.

> Sometimes I use, especially in IPython, to run externally:
> ! python3 -m dis <module>
> ! python3 -m timeit ...
> ! python3 -m pip install ...
>
> And to make this work the same under Windows, the first step which I do
> after installation is to copy `python.exe` and rename it to `python3.exe`
> (for python 2.7 copy `python.exe` and rename it to `python2.exe`). May be
> there is a better way to do this under Windows, I would like to know?

Creating python2.bat and python3.bat instead would take up less
additional disk space and would not need to be modified every time you
reinstall a new release of the same minor version.

> This
> copy-rename works for me, but it will not work for someone who does not
> have administrative rights.

They could put them under their user folder and add the folder to
their path, although that's creeping into power user territory. Then
again, they *are* using IPython...

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

I don't understand. Is 'py -3' that much harder to type than 'python3'
when running in Windows?



More information about the Python-list mailing list