Which Version of Python?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Tue Sep 11 22:11:22 EDT 2012


On Tue, 11 Sep 2012 17:17:14 -0700, Peter wrote:

> If your desire is to "learn" Python then I would stick to 2.7
> 
> My reasoning would be that there are still a significant number of
> packages that have not been ported to 3.x (and may never be ported).

But if all you want is to learn Python, then those packages are 
irrelevant. If I want to learn to write Python code, why should I care 
about SomePackage, regardless of whether it supports Python 3.x or 2.x or 
even 1.x? As a beginner to the language, I don't even know it exists, and 
chances are I'm never going to use it.

(I was happily using Python using only the standard library for about 
seven years before I installed my first third-party library.) 

You may not have intended it this way, but the argument "stick to Python 
2, because packages!" is a typical troll response. It might have been a 
reasonable response six years ago, when there weren't many (or even any) 
major packages that supported Python 3, but now many major packages do 
and most of those that don't are in the process of doing so. Now the 
choice is, paradoxically, much harder because library support is much 
more split: some libraries support 2.x, some 3.x, and some both.

Of course, if you *need* to use SomePackage which only supports Python 2 
or 3, then that will drive your decision to learn Python 2 or 3. But 
consider:

(1) If a package only supports Python 2 now, and *has no plans* to 
support Python 3, I would consider that package more or less a dead end 
and be reluctant to start a new project with it unless I had no other 
choice at all.

(Seriously guys, if you're the developer of a project that only supports 
2.x and you aren't at least *thinking about* supporting 3.x, your project 
is going to be irrelevant to the wider world soon.)

(2) The syntax differences between Python 2 and 3 are very minor. By the 
time you are proficient in one, you will be *easily* be able to jump to 
the other.


> Not having looked at the changes in 3.x (so don't flame me! :-)), it
> would seem that anything you "learn" in 2.7 would be easily transferred
> "up" when and if you feel the need to go to 3.x, 

It goes both ways. But frankly, whenever I drop down from 3.x code to 2.x 
code, I get really annoyed that there's a lot of excellent stuff I cannot 
use.


> but in the meantime
> enjoy the better support of a greater range of packages that are still
> only 2.x compatible!

That's true. But the range of 3.x compatible third party libraries is 
very impressive: it includes numpy and scipy, CherryPy, parts of zope 
(but not yet all of it), pyparsing, an unofficial port of nltk, py2exe, 
and many more. Others, like django, have committed to support 3.x as soon 
as they can drop support for 2.4 or 2.5.

See also:

http://python3wos.appspot.com/

PyPy is now in the process of supporting Python 3. Within a few years, 
Python 3 will be the standard.


> i.e. learning (and using) features of 3.x could
> make it difficult to go "down" when/if you decide you really need to use
> a library that hasn't (and may never!) be ported to 3.x.

Any package that is not ported to 3.x will eventually be as obsolete and 
irrelevant as packages that only support Python 1.5. Python 2.7 will have 
an extended support period, but that won't last forever.

My estimate is that we're past the half-way mark: in another four years, 
the question of "2.x or 3.x" will be irrelevant, people will be asking "I 
want to use library foo, but it only supports 2.7, what should I do?", 
and in eight years, people won't even ask that, they'll just ignore 
library foo as abandoned.


> So in this case, staying with the lower common denominator might be the
> better choice.

Everyone has to make that choice for themselves, based on what libraries 
they intend to use. For those who don't intend to use any libraries at 
all, I think the answer is simple:

Learn the version of Python that comes installed on your computer, or if 
you have to install it yourself, learn Python 3.



-- 
Steven



More information about the Python-list mailing list