running python 2 vs 3
Terry Reedy
tjreedy at udel.edu
Thu Mar 20 18:05:49 EDT 2014
On 3/20/2014 3:07 PM, John Gordon wrote:
> There are two ways (at least!) to run a python script:
>
> 1. Execute the python interpreter manually, supplying the python script name
> as an arugment, like so:
>
> python myscript.py
> python2 otherscript.py
> python3 yetanotherscript.py
>
> This lets you choose on-the-fly which version of python is being used to
> interpret the script.
>
> 2. Execute the python script directly by just typing its name, like so:
>
> myscript.py
> ./otherscript.py
> /other/directory/yetanotherscript.py
>
> Depending on your operating system, this may require:
> a. Permissions on the script file be set to allow execution;
> b. A 'shebang' entry as the first line in the file which specifies the
> program that shall be executed;
c. An association between '.py' and some version of python.
3. Use the python launcher py.exe with version selection.
py -2 myscript.py
py -3 myscript.py
As far as I know, this is only for Windows at present.
--
Terry Jan Reedy
More information about the Python-list
mailing list