Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #68581 > unrolled thread

running python 2 vs 3

Started bynotbob <notbob@nothome.com>
First post2014-03-20 14:58 +0000
Last post2014-03-20 22:19 +0000
Articles 20 on this page of 70 — 21 participants

Back to article view | Back to comp.lang.python


Contents

  running python 2 vs 3 notbob <notbob@nothome.com> - 2014-03-20 14:58 +0000
    Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-20 17:21 +0200
      Re: running python 2 vs 3 notbob <notbob@nothome.com> - 2014-03-20 16:00 +0000
        Re: running python 2 vs 3 Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-03-20 11:14 -0500
          Re: running python 2 vs 3 notbob <notbob@nothome.com> - 2014-03-20 17:10 +0000
            Re: running python 2 vs 3 Chris Angelico <rosuav@gmail.com> - 2014-03-21 04:30 +1100
            Re: running python 2 vs 3 Gary Herron <gary.herron@islandtraining.com> - 2014-03-20 10:45 -0700
            Re: running python 2 vs 3 John Gordon <gordon@panix.com> - 2014-03-20 19:07 +0000
              Re: running python 2 vs 3 Terry Reedy <tjreedy@udel.edu> - 2014-03-20 18:05 -0400
                Re: running python 2 vs 3 alex23 <wuwei23@gmail.com> - 2014-03-21 12:37 +1000
            Re: running python 2 vs 3 Michael Torrie <torriem@gmail.com> - 2014-03-20 15:44 -0600
      Re: running python 2 vs 3 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-20 18:56 +0000
      Re: running python 2 vs 3 Eric Jacoboni <eric.jacoboni@gmail.com> - 2014-03-20 20:07 +0100
        Re: running python 2 vs 3 Ned Batchelder <ned@nedbatchelder.com> - 2014-03-20 16:26 -0400
          Re: running python 2 vs 3 notbob <notbob@nothome.com> - 2014-03-20 21:16 +0000
          Re: running python 2 vs 3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-21 00:32 +0000
            Re: running python 2 vs 3 Ned Batchelder <ned@nedbatchelder.com> - 2014-03-20 21:06 -0400
              Re: running python 2 vs 3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-21 03:16 +0000
                Re: running python 2 vs 3 Chris Angelico <rosuav@gmail.com> - 2014-03-21 14:34 +1100
            Re: running python 2 vs 3 Chris Angelico <rosuav@gmail.com> - 2014-03-21 12:10 +1100
            Re: running python 2 vs 3 Ned Batchelder <ned@nedbatchelder.com> - 2014-03-20 21:20 -0400
      Re: running python 2 vs 3 Alan Meyer <ameyer2@yahoo.com> - 2014-03-20 15:53 -0400
        Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-20 22:08 +0200
          Re: running python 2 vs 3 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-20 20:22 +0000
            Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-20 22:30 +0200
              Re: running python 2 vs 3 Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-03-20 15:43 -0500
              Re: running python 2 vs 3 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-20 20:44 +0000
                Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-20 22:50 +0200
                  Re: running python 2 vs 3 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-20 21:36 +0000
                  Re: running python 2 vs 3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-21 00:59 +0000
                    Re: running python 2 vs 3 Roy Smith <roy@panix.com> - 2014-03-20 21:06 -0400
                      Re: running python 2 vs 3 Chris Angelico <rosuav@gmail.com> - 2014-03-21 13:18 +1100
                      Re: running python 2 vs 3 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-21 09:40 +0000
                        Re: running python 2 vs 3 alister <alister.nospam.ware@ntlworld.com> - 2014-03-21 12:09 +0000
                    Re: running python 2 vs 3 Chris Angelico <rosuav@gmail.com> - 2014-03-21 12:15 +1100
              Re: running python 2 vs 3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-20 22:39 +0000
          Re: running python 2 vs 3 Ned Batchelder <ned@nedbatchelder.com> - 2014-03-20 16:27 -0400
            Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-20 22:42 +0200
              Re: running python 2 vs 3 Ned Batchelder <ned@nedbatchelder.com> - 2014-03-20 16:53 -0400
                Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-20 22:59 +0200
                  Re: running python 2 vs 3 Chris Kaynor <ckaynor@zindagigames.com> - 2014-03-20 14:18 -0700
                  Re: running python 2 vs 3 Ned Batchelder <ned@nedbatchelder.com> - 2014-03-20 17:31 -0400
                    Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-21 00:23 +0200
                      Re: running python 2 vs 3 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-20 22:42 +0000
                      Re: running python 2 vs 3 Chris Angelico <rosuav@gmail.com> - 2014-03-21 10:18 +1100
                        Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-21 07:49 +0200
                          Re: running python 2 vs 3 Chris Angelico <rosuav@gmail.com> - 2014-03-21 16:54 +1100
                            Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-21 08:08 +0200
                              Re: running python 2 vs 3 Rustom Mody <rustompmody@gmail.com> - 2014-03-20 23:51 -0700
                Re: running python 2 vs 3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-21 00:37 +0000
                  Re: running python 2 vs 3 Ethan Furman <ethan@stoneleaf.us> - 2014-03-20 18:23 -0700
                Re: running python 2 vs 3 Rustom Mody <rustompmody@gmail.com> - 2014-03-20 19:20 -0700
          Re: running python 2 vs 3 Chris Angelico <rosuav@gmail.com> - 2014-03-21 10:04 +1100
        Re: running python 2 vs 3 Mark H Harris <harrismh777@gmail.com> - 2014-03-20 15:10 -0500
          Re: running python 2 vs 3 notbob <notbob@nothome.com> - 2014-03-20 21:28 +0000
            Re: running python 2 vs 3 Mark H Harris <harrismh777@gmail.com> - 2014-03-20 16:46 -0500
            Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-21 00:17 +0200
            Re: running python 2 vs 3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-21 00:29 +0000
      Re: running python 2 vs 3 Dan Stromberg <drsalists@gmail.com> - 2014-03-20 13:38 -0700
        Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-20 22:46 +0200
    Re: running python 2 vs 3 Mark H Harris <harrismh777@gmail.com> - 2014-03-20 11:11 -0500
      Re: running python 2 vs 3 notbob <notbob@nothome.com> - 2014-03-20 17:23 +0000
        Re: running python 2 vs 3 Chris Angelico <rosuav@gmail.com> - 2014-03-21 04:29 +1100
          Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-20 19:45 +0200
        Re: running python 2 vs 3 Mark H Harris <harrismh777@gmail.com> - 2014-03-20 12:42 -0500
          Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-20 19:47 +0200
            Re: running python 2 vs 3 Ned Batchelder <ned@nedbatchelder.com> - 2014-03-20 14:45 -0400
            Re: running python 2 vs 3 Mark H Harris <harrismh777@gmail.com> - 2014-03-20 14:36 -0500
        Re: running python 2 vs 3 Terry Reedy <tjreedy@udel.edu> - 2014-03-20 17:52 -0400
          Re: running python 2 vs 3 notbob <notbob@nothome.com> - 2014-03-20 22:19 +0000

Page 1 of 4  [1] 2 3 4  Next page →


#68581 — running python 2 vs 3

Fromnotbob <notbob@nothome.com>
Date2014-03-20 14:58 +0000
Subjectrunning python 2 vs 3
Message-ID<bp0e1eF613oU1@mid.individual.net>
Dumb noob questions: 

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?

nb  

[toc] | [next] | [standalone]


#68583

FromMarko Rauhamaa <marko@pacujo.net>
Date2014-03-20 17:21 +0200
Message-ID<87ob10nbeh.fsf@elektro.pacujo.net>
In reply to#68581
notbob <notbob@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

[toc] | [prev] | [next] | [standalone]


#68584

Fromnotbob <notbob@nothome.com>
Date2014-03-20 16:00 +0000
Message-ID<bp0hk7F613oU3@mid.individual.net>
In reply to#68583
On 2014-03-20, Marko Rauhamaa <marko@pacujo.net> wrote:

> 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.

Ahhh! ....now a shabang I understand.  So, I guess the only way, short
of looking at the actual file, is to include the version in the
filename.  Can I safely assume I can run all 2.7 files w/o a shebang
(which I have not, so far, and was wondering how I got away with that)
and only include a py3 shebang in the py3 files, yes/no?  

nb

[toc] | [prev] | [next] | [standalone]


#68586

FromZachary Ware <zachary.ware+pylist@gmail.com>
Date2014-03-20 11:14 -0500
Message-ID<mailman.8304.1395332703.18130.python-list@python.org>
In reply to#68584
On Thu, Mar 20, 2014 at 11:00 AM, notbob <notbob@nothome.com> wrote:
> Ahhh! ....now a shabang I understand.  So, I guess the only way, short
> of looking at the actual file, is to include the version in the
> filename.  Can I safely assume I can run all 2.7 files w/o a shebang
> (which I have not, so far, and was wondering how I got away with that)
> and only include a py3 shebang in the py3 files, yes/no?

If I understand your question: you're probably better off putting a
shebang line in all of the files that you intend to run directly.  Use
"/usr/bin/env python2" for your Python 2 scripts, "/usr/bin/env
python3" for your Python 3 scripts, and "/usr/bin/env python" for
scripts that can run under either interpreter.  You can also be more
version-specific if you need to; use "python2.7", "python3.3", etc. as
necessary.  That way, you can invoke the script directly and the right
interpreter will run it.  If you're specifying the interpreter in your
command (by calling "python <scriptname>.py", etc), the shebang won't
mean anything anyway.

-- 
Zach

[toc] | [prev] | [next] | [standalone]


#68587

Fromnotbob <notbob@nothome.com>
Date2014-03-20 17:10 +0000
Message-ID<bp0lohF7aqdU3@mid.individual.net>
In reply to#68586
On 2014-03-20, Zachary Ware <zachary.ware+pylist@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.

DOH!  

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)?

nb

[toc] | [prev] | [next] | [standalone]


#68590

FromChris Angelico <rosuav@gmail.com>
Date2014-03-21 04:30 +1100
Message-ID<mailman.8306.1395336668.18130.python-list@python.org>
In reply to#68587
On Fri, Mar 21, 2014 at 4:10 AM, notbob <notbob@nothome.com> wrote:
> On 2014-03-20, Zachary Ware <zachary.ware+pylist@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.
>
> DOH!
>
> 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)?

That's a fine way to do it. Zachary is mentioning an alternative, and
showing that the shebang doesn't hurt (it's a comment to Python), so
go ahead and put the shebang in all your scripts.

ChrisA

[toc] | [prev] | [next] | [standalone]


#68594

FromGary Herron <gary.herron@islandtraining.com>
Date2014-03-20 10:45 -0700
Message-ID<mailman.8307.1395337900.18130.python-list@python.org>
In reply to#68587
On 03/20/2014 10:10 AM, notbob wrote:
> On 2014-03-20, Zachary Ware <zachary.ware+pylist@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.
> DOH!
>
> 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)?
>
> nb

If you mark your script as executable (chmod ...) and include the 
shebang line, and place it in a directory included in your search path 
(mine is ~/bin),  then you run it as you run any installed program:  
Just type it's name followed by any command line args.   I usually 
remove the .py portion of the name as I copy it into my bin directory so 
it really does look like any other installed program.

If you need to be in a specific directory when you run it, then perhaps 
you should consider a bit of a rewrite to remove this constraint.

Gary Herron

[toc] | [prev] | [next] | [standalone]


#68599

FromJohn Gordon <gordon@panix.com>
Date2014-03-20 19:07 +0000
Message-ID<lgfe9q$9hv$1@reader1.panix.com>
In reply to#68587
In <bp0lohF7aqdU3@mid.individual.net> notbob <notbob@nothome.com> writes:

> On 2014-03-20, Zachary Ware <zachary.ware+pylist@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.

> DOH!  

> 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:

     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;

-- 
John Gordon         Imagine what it must be like for a real medical doctor to
gordon@panix.com    watch 'House', or a real serial killer to watch 'Dexter'.

[toc] | [prev] | [next] | [standalone]


#68630

FromTerry Reedy <tjreedy@udel.edu>
Date2014-03-20 18:05 -0400
Message-ID<mailman.8325.1395353168.18130.python-list@python.org>
In reply to#68599
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

[toc] | [prev] | [next] | [standalone]


#68658

Fromalex23 <wuwei23@gmail.com>
Date2014-03-21 12:37 +1000
Message-ID<lgg8lq$74s$1@dont-email.me>
In reply to#68630
> On 3/20/2014 3:07 PM, John Gordon wrote:
> There are two ways (at least!) to run a python script:

 > On 21/03/2014 8:05 AM, Terry Reedy wrote:
> 3. [...]

"Our chief weapon is..."

[toc] | [prev] | [next] | [standalone]


#68631

FromMichael Torrie <torriem@gmail.com>
Date2014-03-20 15:44 -0600
Message-ID<mailman.8326.1395353402.18130.python-list@python.org>
In reply to#68587
On 03/20/2014 11:10 AM, notbob wrote:
> On 2014-03-20, Zachary Ware <zachary.ware+pylist@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.
> 
> DOH!  
> 
> 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)?'

If you want to run a script with python3, just invoke the python3
interpreter:

python3 blah.py

[toc] | [prev] | [next] | [standalone]


#68598

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2014-03-20 18:56 +0000
Message-ID<mailman.8310.1395341804.18130.python-list@python.org>
In reply to#68583
On 20/03/2014 15:21, Marko Rauhamaa wrote:
> notbob <notbob@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
>

The above is also true on windows via the 'Python launcher for windows' 
see http://legacy.python.org/dev/peps/pep-0397/

-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

[toc] | [prev] | [next] | [standalone]


#68600

FromEric Jacoboni <eric.jacoboni@gmail.com>
Date2014-03-20 20:07 +0100
Message-ID<lgfeb3$clj$1@cabale.usenet-fr.net>
In reply to#68583
Le 20/03/2014 16:21, Marko Rauhamaa a écrit :


> 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.

With Arch-Linux, python is python3...

[toc] | [prev] | [next] | [standalone]


#68611

FromNed Batchelder <ned@nedbatchelder.com>
Date2014-03-20 16:26 -0400
Message-ID<mailman.8315.1395347215.18130.python-list@python.org>
In reply to#68600
On 3/20/14 3:07 PM, Eric Jacoboni wrote:
> Le 20/03/2014 16:21, Marko Rauhamaa a écrit :
>
>
>> 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.
>
> With Arch-Linux, python is python3...
>

Yes, and they have been told many times that this was foolish and wrong, 
but it persists, much to our pain.

-- 
Ned Batchelder, http://nedbatchelder.com

[toc] | [prev] | [next] | [standalone]


#68622

Fromnotbob <notbob@nothome.com>
Date2014-03-20 21:16 +0000
Message-ID<bp145kFaoq9U1@mid.individual.net>
In reply to#68611
On 2014-03-20, Ned Batchelder <ned@nedbatchelder.com> wrote:

> On 3/20/14 3:07 PM, Eric Jacoboni wrote:

>> With Arch-Linux, python is python3...
>>

> Yes, and they have been told many times that this was foolish and wrong, 
> but it persists, much to our pain.

I've read that 2.7 is the defacto std for python (default on Slack
14.1).  I installed py3 on Slack box cuz I'd gotten the little
"Programming the Raspberry Pi" book, which is a pretty good lil' book,
clarifying many confusing (to me) python issues.  Only prob is, it's
fer python 3x.  I guess I coulda kept the two platforms separate, but
then raspi has 2X and 3x, also, so I guess I need to get this issue
straight in my feeble geezer head, right outta the gate.  I'm plum
grateful to all you kind folks who are taking the time to educate this
slow ol' curmudgeon.  ;)

nb    

[toc] | [prev] | [next] | [standalone]


#68648

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2014-03-21 00:32 +0000
Message-ID<532b88b0$0$29994$c3e8da3$5496439d@news.astraweb.com>
In reply to#68611
On Thu, 20 Mar 2014 16:26:39 -0400, Ned Batchelder wrote:

> On 3/20/14 3:07 PM, Eric Jacoboni wrote:
>> Le 20/03/2014 16:21, Marko Rauhamaa a écrit :
>>
>>
>>> 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.
>>
>> With Arch-Linux, python is python3...
>>
>>
> Yes, and they have been told many times that this was foolish and wrong,
> but it persists, much to our pain.

How bizarre. I've been looking forward with great pleasure to Fedora 
moving to Python 3 as the standard system Python, expecting that this 
move from one of the big distros will start a chain reaction of others 
doing the same thing. Perhaps Arch-Linux is guilty of being prematurely 
Python 3, a little like those people hauled up to explain themselves to 
the House Unamerican Activities Committee to explain why they were a 
"premature anti-fascist".

I have no idea what "our pain" you are referring to, or who "our" refers 
to. In the three or five years or so since Arch-Linux moved to Python 3 
by default, I don't recall ever seeing even a single email from somebody 
confused by Arch-Linux's move, not here, or on the tutor mailing list, or 
on Python-Dev or Python-Ideas. Nor have I seen any signs of difficulty or 
confusion on Python-related blogs, or StackOverflow.

That's not to say that there has been absolutely none at all. The 
Internet is a big place, and I daresay I've missed something. But given 
how small the Arch-Linux share of the Linux space is, I would be 
astonished if their move caused more than a tiny little ripple. Perhaps a 
paper-cut worth of pain. I expect that there have been far more angry 
words written over this issue than the actual consequences of the move 
itself. Unless you're in the unfortunate situation of having to migrate 
and maintain scripts across a network of mixed Linux distros including 
some that are Arch-Linux, it's difficult to see exactly what pain they 
could be causing even in principle.




-- 
Steven D'Aprano
http://import-that.dreamwidth.org/

[toc] | [prev] | [next] | [standalone]


#68652

FromNed Batchelder <ned@nedbatchelder.com>
Date2014-03-20 21:06 -0400
Message-ID<mailman.8333.1395363997.18130.python-list@python.org>
In reply to#68648
On 3/20/14 8:32 PM, Steven D'Aprano wrote:
> On Thu, 20 Mar 2014 16:26:39 -0400, Ned Batchelder wrote:
>
>> On 3/20/14 3:07 PM, Eric Jacoboni wrote:
>>> Le 20/03/2014 16:21, Marko Rauhamaa a écrit :
>>>
>>>
>>>> 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.
>>>
>>> With Arch-Linux, python is python3...
>>>
>>>
>> Yes, and they have been told many times that this was foolish and wrong,
>> but it persists, much to our pain.
>
> How bizarre. I've been looking forward with great pleasure to Fedora
> moving to Python 3 as the standard system Python, expecting that this
> move from one of the big distros will start a chain reaction of others
> doing the same thing. Perhaps Arch-Linux is guilty of being prematurely
> Python 3, a little like those people hauled up to explain themselves to
> the House Unamerican Activities Committee to explain why they were a
> "premature anti-fascist".
>

My understanding is that Fedora's move will not include making the word 
"python" mean Python 3.  Their move means that Python 3 will be 
installed by default, and that their Python programs that are part of 
the distro will be Python 3 programs.  They can still refer to it as 
"python3".

> I have no idea what "our pain" you are referring to, or who "our" refers
> to. In the three or five years or so since Arch-Linux moved to Python 3
> by default, I don't recall ever seeing even a single email from somebody
> confused by Arch-Linux's move, not here, or on the tutor mailing list, or
> on Python-Dev or Python-Ideas. Nor have I seen any signs of difficulty or
> confusion on Python-related blogs, or StackOverflow.

In the #python IRC channel, there's a steady flow of people who run 
programs they find online, and they get a syntax error on "print", and 
we say, "Arch?" and they say, "yup".

Perhaps I overstated the amount of pain.  But Arch's move prompted a PEP 
to be written explaining what the word "python" should mean:

http://python.org/dev/peps/pep-0394/

Note that they say there that "for the time being" the word python 
should mean Python 2, anticipating that eventually it will be OK to 
change it to Python 3.  But I think that change would always cause 
confusion, and we should not change it over.  I understand that this is 
a controversial view, and don't hold it strongly enough to defend it. :)

>
> That's not to say that there has been absolutely none at all. The
> Internet is a big place, and I daresay I've missed something. But given
> how small the Arch-Linux share of the Linux space is, I would be
> astonished if their move caused more than a tiny little ripple. Perhaps a
> paper-cut worth of pain.

It caused enough of a ripple to get PEP 394 written so that people 
wouldn't do it again.

I expect that there have been far more angry
> words written over this issue than the actual consequences of the move
> itself. Unless you're in the unfortunate situation of having to migrate
> and maintain scripts across a network of mixed Linux distros including
> some that are Arch-Linux, it's difficult to see exactly what pain they
> could be causing even in principle.
>
>
>
>


-- 
Ned Batchelder, http://nedbatchelder.com

[toc] | [prev] | [next] | [standalone]


#68665

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2014-03-21 03:16 +0000
Message-ID<532baeff$0$29994$c3e8da3$5496439d@news.astraweb.com>
In reply to#68652
On Thu, 20 Mar 2014 21:06:24 -0400, Ned Batchelder wrote:

> In the #python IRC channel, there's a steady flow of people who run
> programs they find online, and they get a syntax error on "print", and
> we say, "Arch?" and they say, "yup".

When you install random programs you find online without going through 
your package manager, you have no guarantee that all the dependencies 
will be met. Particularly of third-party libraries, but also of standard 
Python libraries too:

http://bytes.com/topic/python/answers/448757-how-enable-rotor-python-2-4-2-a

If your script uses xreadlines, rotor, or mpz, using "python" to refer to 
both pre-2.4 and post-2.4 will cause breakage. Likewise, I've seen Python 
2.6 break applications because it removed string exceptions. So I'm not 
seeing anything out of the ordinary with Arch: any version change has the 
possibility to break scripts. Python 3 is just more obvious because of 
the change to print, which I daresay is a little more common than rotor...

Arch happens to be at the bleeding edge of that, bless them, but if you 
use Arch, that's what you're letting yourself into. You know what they 
say -- even Slackware users think Arch users are nuts :-)

I've also seen scripts broken because the script used a hard-coded path 
to the Python executable, like /usr/bin/python or /usr/local/bin/python. Or 
because they've hard-coded the version number. Or because they didn't 
hard-code the version number. I haven't seen scripts broken because "env" 
has moved, but I guess that's only a matter of time. Frankly, hash-bang 
lines are a dirty hack, and like all dirty hacks, they work really well 
until they suddenly don't. 



-- 
Steven D'Aprano
http://import-that.dreamwidth.org/

[toc] | [prev] | [next] | [standalone]


#68667

FromChris Angelico <rosuav@gmail.com>
Date2014-03-21 14:34 +1100
Message-ID<mailman.8342.1395372872.18130.python-list@python.org>
In reply to#68665
On Fri, Mar 21, 2014 at 2:16 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> I haven't seen scripts broken because "env"
> has moved, but I guess that's only a matter of time.

That usage is extremely common, and isn't it also specified by POSIX?
I think that's about as dependable as you can get.

Course, it does depend on the user's $PATH...

ChrisA

[toc] | [prev] | [next] | [standalone]


#68653

FromChris Angelico <rosuav@gmail.com>
Date2014-03-21 12:10 +1100
Message-ID<mailman.8334.1395364231.18130.python-list@python.org>
In reply to#68648
On Fri, Mar 21, 2014 at 11:32 AM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> Perhaps Arch-Linux is guilty of being prematurely Python 3...
>
> I have no idea what "our pain" you are referring to, or who "our" refers
> to. In the three or five years or so since Arch-Linux moved to Python 3
> by default, I don't recall ever seeing even a single email from somebody
> confused by Arch-Linux's move, not here, or on the tutor mailing list, or
> on Python-Dev or Python-Ideas. Nor have I seen any signs of difficulty or
> confusion on Python-related blogs, or StackOverflow.
>
> That's not to say that there has been absolutely none at all.

There definitely has been a little. Scripts that began with a "python"
shebang and assumed 2.x would suddenly fail on Arch. But not a huge
amount of confusion. I expect that there'll be a progressive shift -
more distros will start shipping 3.x under the name "python", so
script authors will be more and more aware of the difference, and
before long we'll settle on explicit use of "python2" or "python3" for
anything that matters. Think of the bug reports: "Your program doesn't
work on Ubuntu 14.04, but change the shebang and it'll work, without
breaking it for anything else". Easy fix. And then once Debian and Red
Hat move to 3.x as the default system Python, everyone'll use
"python2" for 2.7 (by that time, I doubt 2.6 or earlier will be
supported much anywhere) and "python" for 3.x, and the transition will
be complete.

ChrisA

[toc] | [prev] | [next] | [standalone]


Page 1 of 4  [1] 2 3 4  Next page →

Back to top | Article view | comp.lang.python


csiph-web