share
Stack OverflowShould I learn Python 2 before 3, or start directly from Python 3?
[+143] [17] blizpasta
[2008-10-04 19:59:18]
[ python python-3.x ]
[ http://stackoverflow.com/questions/170921/should-i-learn-python-2-before-3-or-start-directly-from-python-3 ] [DELETED]

I would like to learn python and currently have access to some good python 2 books. However python 3 is not guaranteed to be backward compatible with python 2. If I were to learn python 2 I have to unlearn and relearn some things when I upgrade to python 3. Also, is there any use/point in learning python 2 or should I just learn python 3 from the start?

(21) Python 3 is not just not guaranteed to be backwards compatible, it is not backwards compatible. - Michael Ekstrand
(8) If you learn Python 3 first, having to use Python 2 will be a great disappointment. - Oleh Prypin
(7) I have this very same question, but it's now almost three and a half years since the accepted answer. Does anyone have a different opinion at the moment? I'm learning Python, and am wondering if I should even bother with 2.x when there's a 3.x - scorpiodawg
(3) 2.x is still widely used by many projects. If you want to make use of these projects, which is very likely, you are better off with 2.x. - Hemm
@casperOne♦ given the votes, this seems pretty constructive to me - Артём Царионов
@АртёмЦарионов votes are by no means a measure of how constructive a post is. It is simy a measure of popularity. - casperOne
(2) @casperOne that seems false. there's certainly a very good correlation between votes and how constructive a post is. is this by your standards constructive? stackoverflow.com/questions/388242/… why hasnt it been closed? - Артём Царионов
@АртёмЦарионов No, it's not constructive, and personally, I would have that closed and deleted as it's a list question. Whether or not that question is to remain open has been hotly debated by many and the current status quo is that question has an exception from a not constructive closing (although it very definitely should be). It is not to be used as an example of why other questions should not be closed as "Not Constructive". - casperOne
@casperOne gotcha! thank you for clarifying - Артём Царионов
[+78] [2008-10-04 20:04:57] jk. [ACCEPTED]

I think you can begin with your Python 2 Books. The major syntax and idioms will be the same with Python 2 and 3.

When Python 3 finally gets released the Python 2 code won't disappear from one day to the other, so I think it won't hurt to know Python 2.

But I would recommend that you keep an eye on the differences of Python 2 and 3. This slides gives you a quick introduction of the changes in Python 2 and 3 [1] (PDF).

[1] http://www.python.org/doc/essays/ppt/euro2008/Py3kEuro08.pdf

(3) Python 3 has already been released. But its uptake is (understandably) slow. Learning Python 2 will better prepare you to modify existing code in the present environment. - Michael Ekstrand
(1) It's now late 2013 and I get the distinct impression that Python 3 is finally here. Major web frameworks Django, Pyramid, Flask, Bottle and their dependencies now support Python 3. ipython, numpy and scipy support python 3. The "Python 3 Wall of Shame" is now the "Python 3 Wall of Superpowers" python3wos.appspot.com. And I've started to see more documentation cater to python 3 and even use it as default. Until recently I'd been recommending python 2 to people who asked me this question, but going forward, my answer is going to be python 3. - mindthief
1
[+38] [2008-10-04 20:04:41] John Millikin

Learn Python 2. Most tutorials and libraries are still written for Python 2. Furthermore, the actual differences between 2.6 and 3.0 are minor -- most of them are simply removal of deprecated features.


(5) “ the actual differences between 2.6 and 3.0 are minor” — woah, really? Strings vs. Unicode vs. bytes is minor? - Paul D. Waite
(8) Anybody using Python 2 should be using unicode already anyway; in 2.6, you can enable Py3k-style unicode and byte literals. - John Millikin
2
[+15] [2008-10-04 22:41:53] Phoenix

I will be in the minority opinion, but: Start with Python 3.

The final release is coming out this month [1] (Oct 2008), beta releases are already around.

Yes, 2.x Python is more useful right now, but if you're just learning it, you are not likely to be using it right now. It's too late to get started on technology that will be obsoleted this month.

Also, like others have said, the differences between 3 and 2.x are minor. You will be able to use your Python 3 skills to work on 2.x projects, with minor tweaks.

The bottom line is this: you can really start with either and be fine. Personally, I would plan for the future.

[1] http://www.python.org/download/releases/3.0/

(25) 2.5 years later, tons of Python 2 code is being written. I think obsoleted wasn't the right word. - Eric Wilson
(9) and 4.5 years later it's still being written and required by employers. - Kupiakos
(2) 4.7 years later and I just installed v2.7 in order to work with the Google Python SDK. Heck, not even Google is supporting Python 3 to run in its "App Cloud" services. What does that tell you? - Dreadful_Code
3
[+7] [2008-10-04 20:02:24] Jason Baker

Python 2 is still going to be around for a while. Thus, if you plan on using it for a project right now, I'd suggest going with it as it's more mature and has the most library compatibility.

If it's just for the sake of learning or you don't have any immediate uses for python, you can take your pick. Python 3 has lots of nice features, but it will still be a while before it will overtake Python 2 in terms of compatibility.


4
[+3] [2008-11-12 17:47:20] Matt

It might be useful to think about whether or not you will need to write C extensions. The API for that will change from 2.x to 3.0.

You might want to look into what other libraries you are planning to use before jumping in and finding out later that you have to re-factor all your extensions. In that respect 2.6 is a safer bet for now.


5
[+2] [2008-10-04 20:08:31] ConcernedOfTunbridgeWells

Start with Python 2 as it's going to be in use for quite a while. In practice the differences in the language from 2 to 3 should not be significant work to learn.


6
[+2] [2008-11-12 18:15:25] John T

May as well learn the older version first, sure you will have to learn some new things upon release of 3.0 but you will already know the majority of the language. On the plus side, you will also be able to understand older code, which is important if your future boss asks you to update some legacy code you will know the new implementations, it's kind of hard to update code when you aren't aware of what the old functions do in the first place. Not only updating legacy code, but understanding it is also a good quality to have if people come for you to help or post it on a particular website (hint hint) and ask for help.

best of luck


7
[+2] [2009-04-26 12:18:42] e-satis

Hum... Please everybody stop being paranoid. This is about learning Python, not creating a master application. At a basic level, V2 and V3 differences are really not such a headach.

Pick up any, if something breaks when you port your code, it will be easy to find it. Guido have done things well and errors are really very explicit. V2.5/6 works with the most of the libs, V3 is faster and got the nice division behaviour...

Don't worry about such concern while learning. I code in pure Python, in Django, in pyGTK, in pyWx and Plone with version going from 2.2 to 3, and the worst trouble I have is usually print becomming print() :-) Ok, sometimes it's a pain, but really for a noob it's a no brainer.


8
[+2] [2009-06-13 10:31:23] Achimnol

It is possible to install both Python 2.6 and 3.0 on most systems. I usually set Python 2.6 as main interpreter and launch 3.0 with 'python3' command (how-to this depends on your platform). So my recommendation is that just install both and develop practical softwares on 2.6 at the moment while test and adapt yourself to 3.0 via beginning from small scripts.

I think the most important thing if you consider porting your works from 2.6 to 3.0 later is that string-unicode problem. Many other differences could be converted with auto-conversion tool provided officially though I haven't tested it thoroughly yet, but I think logical understanding for encoding problems should be applied when you write codes in 2.6.


9
[+2] [2011-08-25 01:10:28] Hitesh Kumar

If I were you, I would learn Python 2.7 or Python 3. Python 3 is much more elegant, and Python 2.7 has a lot of fluidity that Python 3 has, as well as the libraries. However, if you plan to learn other programming languages, learn Python 3. Python 3 can relate much more to another programming language than any other version of Python. Python 3 is cutting edge and beautiful to look at, so that's why I went with it. And don't worry about libraries too much (unless it's really important), as they'll catch on. A beginner wouldn't have much use of most libraries anyways!


10
[+2] [2011-09-26 11:57:02] Abe

This PDF [1] shows how many changes there are between the two versions. It may be helpful when deciding.

[1] http://ptgmedia.pearsoncmg.com/imprint_downloads/informit/promotions/python/python2python3.pdf

11
[+1] [2009-05-14 00:37:41] Stamenko Radosevic

I've started with 3.0 recently, and I was asking myself the same question as you are. After searching the net for a couple of hours I decided to go with 3.0. However, I intend to learn the language for creating relatively small standalone applications for my professional work, which is mostly for solving mathematical problems (civil engineering--I'm in my 3rd year now). I was not concerned about the "commercial side" of that decision.

If you are in the same "interest group" as I am, then I suggest you to go with 3.0.

Good luck.


(4) My background is civil engineering and this is why I cannot imagine using Python 3 for any work—I use numpy constantly, which (like most important libraries) has not been ported to 3. - Mike Graham
From the documentation of numpy: NumPy and SciPy support the Python 2.x series, beginning with version 2.4, as well as Python 3.1 and newer. The first release of NumPy to support Python 3 was NumPy 1.5.0. Python 3 support in SciPy starts with version 0.9.0. - Hakan Deryal
12
[+1] [2009-08-27 14:53:02] Andz

I don't think you will be making a major mistake choosing either. Python 2 and Python 3 seem to be similar enough that moving between one to the other as the need arises will not be a big deal.


13
[0] [2009-05-30 09:34:50] Sorin

3.0.1 is the best choice, even if there are no third-party. In some month when you will need it you will find it :)


14
[0] [2012-04-07 20:31:45] clark

If you are a hobbyist learn 3.x, otherwise pick 2.5

Company's do not upgrade solid working code into a new language unless they have to. Companies still use COBOL and FORTRAN because of the cost, and bugs, that changing to another language entails. The nuts at Python 3.0 that think that being incompatible with production code will eventually work out. Unless they shut 2.x down to force a change, I have my doubts this will happen.


15
[-1] [2011-07-13 20:31:02] Chris Hayes

Learn 2 first for one major reason:

  • all the major libraries for getting stuff done are in vr 2

when you need library assistance for, say, AWS... it's all written for 2. or for My Sql access, all written for version 2. And this goes on and on. All these support libraries you need to successfully deploy stuff are built on 2 and not 3 (yet).


16
[-3] [2008-11-12 17:49:40] Emil Royzman

You should learn Python 2.5 first. Why not 2.6? Because 90% of 3rd-party modules is written for 2.5 version (like py2exe)


17