running python 2 vs 3

Terry Reedy tjreedy at
Thu Mar 20 23:05:49 CET 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
>       python2
>       python3
> 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:
>       ./
>       /other/directory/
>     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
     py -3

As far as I know, this is only for Windows at present.

Terry Jan Reedy

More information about the Python-list mailing list