[Python-ideas] Windows temporary file association for Python files

Paul Moore p.f.moore at gmail.com
Mon Oct 22 13:44:04 CEST 2012


On 22 October 2012 11:51, anatoly techtonik <techtonik at gmail.com> wrote:
> I wonder if it will make the life easier if Python was installed with
> .py association to "%PYTHON_HOME%\python.exe" "%1" %*
> It will remove the need to run .py scripts in virtualenv with explicit
> 'python' prefix.

In Python 3.3 and later, the "py.exe" launcher is installed, and this
is the association for ".py" files by default. It looks at the #! line
of .py files, so you can run a specific Python interpreter by giving
its full path. You can also specify (for example) "python3" or
"python3.2" to run a specific Python version.

A less known fact is that you can define custom commands for py.exe in
a py.ini file. So you can have

[commands]
vpy=python

in your py.ini, and then start your script with #!vpy to make it use
the currently active Python (whichever is on %PATH%).

Hope that helps,
Paul



More information about the Python-ideas mailing list