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?
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.pdfLearn 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.
unicode
already anyway; in 2.6, you can enable Py3k-style unicode and byte literals. - John Millikin
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/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.
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.
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.
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
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.
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.
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!
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.pdfI'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.
numpy
constantly, which (like most important libraries) has not been ported to 3. - Mike Graham
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.
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 :)
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.
Learn 2 first for one major reason:
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).
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)