views:

1937

answers:

6

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)

A: 

It depends on your audience. If it's a general audience, and you plan to leave it posted for a long time, I'd suggest looking forward and going with 3.0. On the other hand if it's for a project or group that's going to be doing work in the near future, Python 2 probably make more sense.

acrosman
+9  A: 

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

contagious
He is called "van Rossum" and not "von". And you should begin the sentence with a capital V.
hcs42
Van Rossum also says that it will be at least another year before you have to learn 3.0: http://www.artima.com/weblogs/viewpost.jsp?thread=211200
Glyph
+1  A: 

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.

kanja
A: 

The differences are small enough that it's really not going to matter much.

fivebells
the underlaying won't, but for a beginner, there is a huge difference between "print "hello world"" and "print("hello world")"
contagious
Hmm, I'd be really interested to read the study which established that. Can you point me at it?
fivebells
Alex, I agree with you. The differences may be significant (if straightforward) for backporting established projects, but they're small enough that if you know one version well, you can get the hang of the other in a few minutes. So it doesn't much matter, but 3.0 is the future, so I say learn it.
Dan
what i meant was that teaching someone to use print "hello world" is alot different that teaching someone to use print("hello world") from a syntax perspective. the tutorial would contain enough differing content to be noticable
contagious
it seems almost exactly the same to me, TBPH. one has parentheses, one doesn't. from a beginner standpoint that's the only difference.it's even more cohesive - no special casing for 'print' which isn't really a function.
Claudiu
+2  A: 

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.

Dan
+9  A: 

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.

Glyph
thanks.. very good points to consider.
Corey Goldberg