Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tutorial for Python - Should I use 2.x or 3.0? [closed]

Python 3.0 is in beta with a final release coming shortly. Obviously it will take some significant time for general adoption and for it to eventually replace 2.x.

I am writing a tutorial about certain aspects of programming Python. I'm wondering if I should do it in Python 2.x or 3.0? (not that the difference is huge)

a 2.x tutorial is probably more useful now, but it would be nice to start producing 3.0 tutorials.

anyone have thoughts?

(of course I could do both, but I would prefer to do one or the other)

like image 679
Corey Goldberg Avatar asked Oct 16 '08 19:10

Corey Goldberg


4 Answers

Start with 2.x. Most existing libraries will be on 2.x for a long time. Last year, Guido himself said that it would be "two years" until you needed to learn 3.0; there's still another year left. Personally, I think it will be longer. People writing code on 2.x can learn how to use the 2to3 tool and have code that works on both versions. There is no 3to2, so code written for python 3 is significantly less valuable.

Thats not to mention how disappointing it will be for your students to learn that python 3 is not installed on their Linux computer ("/usr/bin/python" will be python 2.x for the next 5 years, at least), that there is no django for python 3, no wxwindows for python 3, no GTK for python 3, no Twisted for python 3, no PIL for python 3... the real strength of Python has always been in its extensive collection of libraries, and there are very few libraries for python 3 right now.

If your tutorial is well written, you should easily be able to update it to python 2.6, 2.7, and eventually python 3.

like image 125
Glyph Avatar answered Oct 05 '22 23:10

Glyph


Van Rossum (creator of python) explains that "if you're starting a brand new thing, you should use 3.0." So most people looking to get started should even START with 3.0. It will be useful especially since there are probably very few out there now.

the article

like image 37
helloandre Avatar answered Oct 05 '22 23:10

helloandre


Learn Python 3.0, as contagious suggests.

Python 2.x is not very different, there seems to be a great deal of FUD about the rather minor differences between them. Sure, the differences are great enough that most programs will need to be modified, but almost all of the modifications are straightforward (like changing print statement to print function).

In fact, Python 2.6 can optionally enable all the new syntactic features of Python 3.0. It's a very well-thought-out transition process.

like image 40
Dan Lenski Avatar answered Oct 06 '22 01:10

Dan Lenski


Python 2.x has been out long enough to build up quite a few tutorials already, but 3k has much less resources available. Some intro level 3k stuff would probably see more general purpose use. So unless you're tailoring this to a specific sub domain that lacks any python resources, 3k would be of greater use.

like image 26
gone Avatar answered Oct 05 '22 23:10

gone