running python 2 vs 3
gordon at panix.com
Thu Mar 20 20:07:39 CET 2014
In <bp0lohF7aqdU3 at mid.individual.net> notbob <notbob at nothome.com> writes:
> On 2014-03-20, Zachary Ware <zachary.ware+pylist at gmail.com> wrote:
> > If you're specifying the interpreter in your command (by calling
> > "python <scriptname>.py", etc), the shebang won't mean anything
> > anyway.
> I was following you, fine, until that last sentence. Then how should
> I invoke the scripts? ....as your example is exactly how I've been
> doing it with 2.7, as per Learn Python the Hard Way. Simply
> ./<scriptname>.py from the appropriate directory (assuming I keep both
> vers in separate dirs)?
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:
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:
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;
John Gordon Imagine what it must be like for a real medical doctor to
gordon at panix.com watch 'House', or a real serial killer to watch 'Dexter'.
More information about the Python-list