Hacker News new | ask | show | jobs
by stinos 1889 days ago
if you happen to run a script that executes "python3"

Funny thing is, this is actually wrong on Windows and always has been. Unless I'm missing something. I recently traced back the earliest python3 installer on the official ftp site of python.org and even that one didn't have a python3 command. No official installers seem to have had it. Nor does an Anaconda install. So I don't really know why the 'official' (that is, the one on the MS store) is pushing python3 as a command (apart from 'other OS do have this'). Anyone has any insight on this?

Yes, the command line itself has ads

Technically it's just an executable in the PATH so anything, including any terminal application, which uses that gets it.

helpfully adds an explorer shell link to "Open in Visual Studio

Care to post the link to that installer? Never saw that, curious to see which one that is.

1 comments

The official Python installer in the Windows App store installs a handler for python and python3 .. or rather, the stub of the handlers already on your system calls into the app store and it's behavior changes after installation. Regardless of the technical implementation, after you install Python3 from the app store, running python3 from the command line will open the Python interpreter.

No clue why the standard non-app store installer doesn't add python3 to the path to mimic this behavior.

The standalone installer is quite old and frankly weird. You're meant to use `py -3` or something like that. I don't know why it works this way. Tbh I think the official store installer works much more sensibly.
Back when I had a large python2 and python3 code bases side by side, I had a small handler that I installed for .py files that read the #! line and tried to figure out which python version to call, and defaulted to Python3 if it couldn't find a #! line. I always felt this was the "correct" way of solving this.

Nowadays, I just only install Python3 on machines, so it's not really a problem for me anymore.