Python 2 vs 3

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Python 2 vs 3

Owen Densmore
Administrator
Just looking at Python 2.x vs 3.x, its not at all 3.x is better.  But then I'm not a python hacker.

Any expert suggestion on whether 2.x or 3.x is best for most new programs?  .. and why?

Thanks,

   -- Owen


============================================================
FRIAM Applied Complexity Group listserv
Meets Fridays 9a-11:30 at cafe at St. John's College
lectures, archives, unsubscribe, maps at http://www.friam.org
Reply | Threaded
Open this post in threaded view
|

Re: Python 2 vs 3

Bruce Sherwood
(Perhaps someone can copy this to the discuss group if appropriate, to
which I'm not subscribed.)

3.x is indeed "better" than 2.x. The main point of 3.x was to make
Python cleaner in various ways, especially by eliminating stuff that
had been long deprecated. I advise new users of Python to start with
3.x, because it represents the future of Python. It is the case that
for casual use there's almost no visible difference other than this:

        print 'hello' -> print('hello')

However, it's a long process for all the large number of Python
modules to catch up. For example, the important fast array module
numpy, and the large scientific package scipy (scipy.org) have binary
downloads for 3.x for Windows but not for Mac, for which one must
build from source using the standard dist-utils mechanism (the Mac
download for VPython for Python 3 includes numpy). This isn't a
showstopper, but to me it's annoying. I suppose they feel that
scientific users are savvy enough to use dist-utils easily, and there
is a compiler available on all Macs but not on all Windows machines,
hence the need for binary downloads for Windows.

There's a significant advantage to Python 3.x for novice programmers,
in that it treats 1/2 as 0.5 (like Javascript), whereas without a
special invocation (from __future__ import division) Python 2.x treats
1/2 as 0 (like C). And a novice user of Python is unlikely to need
immediately a currently unavailable module.

Incidentally, the Python developers did something quite interesting to
bridge from 2.x to 3.x. They offer a program 2to3.py which does quite
a good job of converting a 2.x program to 3.x. They also implemented
some 3.x features in the later 2.x versions, in parallel with older
structures, so that people could try out the future. The trick of
"from __future__ import division" is another example of this sort of
thing.

Bruce

On Sat, Jun 18, 2011 at 8:49 PM, Owen Densmore <[hidden email]> wrote:

> Just looking at Python 2.x vs 3.x, its not at all 3.x is better.  But then I'm not a python hacker.
>
> Any expert suggestion on whether 2.x or 3.x is best for most new programs?  .. and why?
>
> Thanks,
>
>   -- Owen
>
>
> ============================================================
> FRIAM Applied Complexity Group listserv
> Meets Fridays 9a-11:30 at cafe at St. John's College
> lectures, archives, unsubscribe, maps at http://www.friam.org
>

============================================================
FRIAM Applied Complexity Group listserv
Meets Fridays 9a-11:30 at cafe at St. John's College
lectures, archives, unsubscribe, maps at http://www.friam.org