tags:

views:

238

answers:

6

Possible Duplicate:
Should I learn python 2.x or start learning python 3

I'm just starting to learn Python, but just to use my time more efficiently, would you recommend to read Python2 or start directly from Python3? I'm about "Dive into Python". Is it similar to start reading PHP4 or PHP5? I'm trying to understand whether it's worth spending time on Python2 literature.

+5  A: 

If you plan to use Python for real production work, IMHO Python 2.6/2.7 is still the way to go, since most major libraries haven't ported to v3 yet.

However, if you just want to learn Python for the sake of expanding your horizons and understanding what the language is about, by all means go with version 3.


P.S: I realize this question is a duplicate of at least 2-3 other questions. But it's one of those questions that has to be asked every few months, since these things are in constant flux, and the "current opinion" matters.

Eli Bendersky
"these things are in constant flux" Really? I don't see any changes in both 3rd party libraries availability and in widely spread opinion on this situation. "Python 2 for real work, Python 3 for fun". I hear it for 2 years. By the way what's the reason of such slow transition? Is it the fact that many of the libraries written in C and not in Python?
kemiisto
@kemiisto: to me it seems like the chicken/egg problem. Library implementers see no reason investing effort before there are enough v3 users, and users see no reason switching before the relevant libraries are there. That said, there is a (slower than desired, but still positive) trickle of porting going on, so eventually (I hope!) the switch will happen
Eli Bendersky
@kemiisto, People recommending "Python 3 for fun" must have a different idea of fun than I have. What's fun about not being able to write software that does stuff?
Mike Graham
@kemiisto, The transition has been slow because it takes work to port and people haven't put forth the large amounts of work for the small amounts of benefit for many major projects. Many of the most important, largest libraries are written as C-extensions, which are especially hard to port. A lot of pure-Python(ish) stuff hasn't been ported because, even though 2to3 is pretty good, it still takes lots of work to port. Consider that 2to3 has no idea what semantic changes to make to correctly translate uses of bytestrings/unicode between versions.
Mike Graham
@Eli Bendersky: thanks for explanation.@Mike Graham: you are perfectly right. Any creative occupation (like programming) can be fun when one is able to produce some useful stuff. And thanks for clarifications too.
kemiisto
I'm producing plenty of 'useful stuff' using just Python 3.1, the standard library and PyQT4. Unicode strings alone are worth the upgrade if you don't need any other libs.
Don O'Donnell
+1  A: 

As Python (2.6.4) is still widely used, i would recommend starting with it. If you understand Python2, it will be easy for you to learn Python3...

ptikobj
A: 

You should always use what the community uses, which is Python 2.5-6 imho. Most of the 3th party libraries don't support 3.x yet so there is not a real big reason to switch onto Python3k for now.

wvd
+1  A: 

Learn Python 3. Speaking from experience, it's not so hard to use 2 if you learned 3. If more people are impatient to use 3rd party libraries with 3, then perhaps some of them will contribute to the porting effort and we can all move to 3 sooner.

ptomato
+1  A: 

I'm going to strongly suggest going with Python 3. The issue is that you sound like a new young programmer and as such will be at it awhile. As such you might as well start learning the version that will be the standard for the next few years going forward.

As others have noted there are issues with some third party libraries but that is quickly changing. Frankly I'm going to flat out say you should avoid many of these libraries anyway until you get a good portion of Python under your belt. Also you might want to lok for better or more varied Python texts, hopefully something leveraging well the new features in Python 3.

Realize that, as already been pointed out, the differences are not huge. I'm just of the opinion that you should educate yourself for the future not the past. Especially if you develop code for yourself or customers.

Dave

David Frantz
Thanks for the comments.. well I have 12 year experience in programming with c/c++/c#/php/mysql/as... and as I said in above comment by this time I already have idea what it is all about. Quick self answer would be to start from Python 2.
Michael
+1  A: 

Python 3 is a great place to start for those "with no baggage" (meaning no existing Python code or apps, no libraries/dependencies that haven't been ported to Python 3 yet, etc.).

However on the other hand, although Python 3 is here, most of the industrial world still runs on Python 2, so if you do need to create an app to run today using the libraries and packages available to you, that's where you should start. If you do, use any release 2.6 or newer as they have features backported from 3.x to help you start thinking in a 3.x kind of way. :-) If you learn one, it's easy to adapt to the other (and vice versa).

On a related note, I had the publishers add two new appendices (C & D) to the latest printing (5th!!) of my book, Core Python Programming, one on Python 3.x and the other on the importance of 2.6 and the role it plays in helping users to transition to Python 3.

Finally, I've been giving talks on Python 3 and covering the main differences from Python 2. Here's one that I gave a PyCon a few months ago which includes the slide preso.

wescpy
Hi, the resources you mentioned as well as your advice is valuable. Actually by the time I wrote this I started to read Diving into Python2 and by now I can say that more or less I understand the structure and concept of the language. So definitely it was worth reading Python2. Yes, I'm going to use it for some real world tasks.
Michael
wescpy