running python 2 vs 3

Marko Rauhamaa marko at pacujo.net
Thu Mar 20 11:21:42 EDT 2014


notbob <notbob at nothome.com>:

> I've installed python 3.3 on my Slack box, which by default comes with
> python 2.7. I know how to fire up the different IDLE environments, but
> how do I differentiate between the scripts? IOW, up till now, I've
> used .py on all my 2.7 files. How do I know not to run a .py in
> python3 or visa versa? Or do I? What's the excepted convention for
> differentiating between the two?

That's a bit of a sore spot.

On a linux box, the initial line of the script indicates the
interpreter:

   #!/usr/bin/env python2

for Python 2.x

   #!/usr/bin/env python3

for Python 3.x.

All tutorials will tell you to start it with

   #!/usr/bin/env python

which will start python2 on all (?) existing linux distros, but is
expected to start python3 within the next decade.


Marko



More information about the Python-list mailing list