[Tutor] Which version of python should i use?

Dave Angel davea at davea.name
Mon May 20 12:38:45 CEST 2013


On 05/20/2013 05:59 AM, Amal Thomas wrote:
> hi,
>     I am a beginner. I am using a unix sytem (ubuntu 12.10). Python 2.7.3
> is installed in my system. I found out that Python has version upto 3.3.2.

Welcome, and thanks for telling us your environment up front.


> Should I update my python version?

No.  Your OS has lots of dependencies on that installed Python, and if 
you remove that one (eg. replace it), many things will stop working.

HOWEVER, you can install a second Python, of whatever version, and use 
that for all your own experimenting and learning.  So the question is 
which one you should use for learning.  My comments at the end.

> Is the syntaxes of the each version
> different?
>

Yes.  Not only syntax but semantics as well.  Version 3.0 was 
deliberately a breaking update, where many of the painful gotchas in the 
language were fixed, even if it meant things were incompatible.  There 
is a 2to3 utility, but the transition can be painful for large programs.

Which one should you learn on?

#1 --- if you're committed to a particular tutorial, use the version 
that matches the tutorial.  At your stage, you don't want to have to 
convert every example in your head before getting it to work.

#2 --- If you have a particular library or libraries that you plan to 
use, and it's only currently available for one version, then use that 
version.

#3 --- If neither of the above apply, then use 3.3 or the soon-coming 3.4.

What's different?  For a beginner, the most noticeable different is that 
the print statement in 2.x was replaced by a print function in 3.x  For 
really simple cases, that just means slap a parentheses around the 
argument(s).  But the print statement has syntax for redirecting to a 
file, while the print function has a parameter.  And the technique for 
suppressing the trailing newline is different.  Etc.

The second most noticeable difference is that 3.x handles Unicode 
directly, so that a string is Unicode, and if you want bytes, those are 
different.




-- 
DaveA


More information about the Tutor mailing list