tags:

views:

12928

answers:

13

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?

+5  A: 

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.

Jason Baker
+27  A: 

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.

John Millikin
“ the actual differences between 2.6 and 3.0 are minor” — woah, really? Strings vs. Unicode vs. bytes is minor?
Paul D. Waite
Anybody using Python 2 should be using `unicode` already anyway; in 2.6, you can enable Py3k-style unicode and byte literals.
John Millikin
+34  A: 

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 (PDF).

jk
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 E
+1 Those slides are a great summary, even now.
kaizer.se
+1  A: 

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.

ConcernedOfTunbridgeWells
+2  A: 

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

The final release is coming out this month (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.

Phoenix
+2  A: 

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.

Matt
A: 

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)

Kirill Titov
+1  A: 

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

John T
A: 

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.

e-satis
+1  A: 

Ive 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 am intending to learn the language for creating small (relatively) standalone aplications for my proffesional work, mostly for solving mathematical problems ( civil engineering, Im 3. year now ) so i was not concerned abaut "comercial side" of that decision.

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

good luck

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
+1  A: 

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

A: 

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.

Achimnol
A: 

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.

Andz