Python 2.7 and 3.9

MRAB python at mrabarnett.plus.com
Wed Feb 17 09:44:32 EST 2021


On 2021-02-17 14:09, Thomas Jollans wrote:
> On 16/02/2021 22:16, Ethan Furman wrote:
>> Kevin, please reply to the list (preferably Reply-to-list, or 
>> Reply-all), that way others can chime in with help.
>>
>> On 2/16/21 12:55 PM, Kevin M. Wilson wrote:
>>
>>> Windows 7 OS, and typically run in conjunction with testing SSD', as 
>>> for stand alone scripts.
>>> Those require: python BogusFile.py. I too was expecting users to 
>>> type: python my_Script.py!
> 
> On Windows, you should use the py.exe launcher:
> 
> py -2 python2_script.py
> 
> to run an old script, and
> 
> py -3 python3_script.py
> 
> or
> 
> py python3_script.py
> 
> to launch a new script. AKAIK, the launcher is always installed with
> recent versions of Python on Windows.
> 
The scripts simply need to start with a shebang line that specifies the 
Python version. Then it's just:

py python2_script.py

py python3_script.py

> 
> You could set up the PATH such that 'python' is python 2.7, and 'py'
> calls python 3.x. Have a look at the docs to figure about what other
> options py.exe gives you (such as shebang lines)
> 
> Docs:
> https://docs.python.org/3/using/windows.html#python-launcher-for-windows
> 
> PEP: https://www.python.org/dev/peps/pep-0397
> 


More information about the Python-list mailing list