tags:

views:

412

answers:

6

Possible Duplicate:
To learn python 2 then 3, or 3 from the start?

I am going to start learning Python soon and I am unsure whether or not I should learn Python 2 or 3 (for general programming, no web development). I know this has been asked before but those were old, before Python 3 was stable enough for production. So is it worth learning Python 3? Other than syntax, are there any performance improvements?

+5  A: 
KennyTM
thanks, most likely will start with Python 2, seems more stable.
Dr Hydralisk
Stability has nothing to do with it. Python 3 is as completely stable as Python 2. The accepted answer to the question you're duplicating is clear. Stability has no part in the answer.
S.Lott
I'd start with 3, because of the better html, http and urllib libraries.
Rich Bradshaw
+1  A: 

If you have experience with .NET you may want to consider IronPython. It is quite mature and you will be able to concentrate on learning the syntax and programming style, instead of focusing on new libraries etc. I have taken this approach myself a few weeks ago.

Good luck :-)

Rune
+2  A: 

I think it’s a bit like HTML 4 vs. HTML5 — Python 2 will be around for a few years, but Python 3 is where we’re going, and we’ll mostly be happier when we get there.

So learn Python 2, because you’ll need to know how that works, and then learn how Python 3 is different.

Dive Into Python3 is probably a good resource. (I haven’t read it fully myself yet, but it does highlight the changes to strings and unicode, which seems like the biggest difference.)

Oh, and on Python3 performance, obviously it depends what you’re using it for. But:

Paul D. Waite
(Let’s see... HTML5, check... Dive into X, check... yup, standard Paul D. Waite answer.)
Paul D. Waite
+1 for the comment almost as much as the answer :-)
Steve314
Dive into Python is full of inaccuracies and awful code examples. :(
Mike Graham
@Mike Oh really? That’s bad news. Could you link to some details?
Paul D. Waite
A: 

I'd second the recommendation for IronPython (which is Python 2.6 at present) especially as it is supported in Silverlight so runs client-side in the browser, as shown in this interpreter console example.

Andy Dent
Typical, mention some MS technology and get downvoted by a rabid anti-MS person (only reason I can think of for the downvote).
Andy Dent
A: 

Python 2.0 has a lot more support and libraries available compared to Python 3. A major reason for that being Python 3 is not backwards compatible.

But as a newbie not to long ago, I started with Python 3 and then later have had to do some development in Python 2 because of support. Google Wave Python API and Google Apps in general support Python 2.

As far as learning goes Python 3 is somewhat more intuitive with changes to how ordering works and how number types are implemented (see link below for full reference) and other changes.

As far as which to learn it is totally up to what are you going to do afterwards. If you don't have to deal with legacy stuff, Python 3 would not be a bad idea.

Documentation of changes to Python 3.1 would be available here: http://docs.python.org/3.1/whatsnew/3.0.html

Ashish
+2  A: 

Python 3 has been stable for years; what is missing is library support. There are not many tasks for which Python 3 is a better choice than Python 2 at the current time for this reason. You say you will be doing "general programming", so I don't know what your field is, but it is hard to imagine you won't be writing an app that should rely on twisted or numpy or some other library that has not even started a push to port to Python 3.

At the Python level, the differences between recent 2.x releases and Python 3 are not all that big. You will have no problem picking up Python 3 if you become a good Python programmer using Python 2.

Mike Graham
You post a convincing argument, I guess I will start with Python 3, it just does not feel stable.. Python 3.1 does not sound like a stable version, should be an even number(i know, im weird like that).
Dr Hydralisk
Yes, that is silly. Even numbers and stability have nothing to do with each other in Python's numbering scheme. Still, stability aside, it still makes a lot more sense to start with Python 2 today.
Mike Graham