On 1/1/2024 12:26 PM, Mats Wichmann via Python-list wrote:
On 1/1/24 07:11, Thomas Passin via Python-list wrote:

Here's how to find out what program Windows thinks it should use to run a ".py" file.  In a console:

C:\Users\tom>assoc .py
.py=Python.File

C:\Users\tom>ftype Python.file
Python.file="C:\Windows\py.exe" "%L" %*

That's not enough. There is now (has been for a while) a layered system, and this gives you just one layer, there may be other associations that win out.

Per somebody who actually knows:

> The only way to determine the association without reimplmenting the shell's search is to simply ask the shell via AssocQueryString. Possibly PowerShell can provide this information. – Eryk Sun

"Possibly", eh? In fact, on my system those layers must be in effect, since ftype claims that the "py" launcher will be used but in actual fact the old Python 3.9.9 is used instead, as I wrote earlier. This is verified by this tiny Python script:

# Optional shebang line here
import sys
print(sys.executable)

Then run it with "py", a proposed shebang line, its plain name on the command line, whatever. That will tell you for sure which Python executable gets launched by which technique.

On Windows 10, a shebang line gets ignored in favor of Python 3.9.9 (if invoked by the script name alone) or Python 3.12.1 (if invoked by the "py" launcher).

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to