Recent versions of Python for Windows install a script called py
that will do what you want.
You can either do py -3 script.py
to explicitly tell the launcher that you want to use Python 3
or put something containing "python3" on the first line in a comment (ideally #!/usr/bin/env python3
for compatibility with other systems...) and just run script.py
; the installer associates *.py
files with the launcher, which in turn determines the version to run by looking at the first line of the script.
This mechanism is described in PEP 397.