What is the difference between Python 3.2 and 3.1? - python

newb coder here
I have decided to dive headfirst into python and discovered there are different versions of python such as Python 3.2, 3.1 etc. Could someone please tell me if there is any difference? if I learn an older version would i have to re-learn a newer version or is it just an update to the libraries and stuff? Sorry if it seems trivial, I'm new to this

Check out the Python 3.2 release notes for specifics. You shouldn't notice any syntax differences or issues between 3.2 and 3.1, especially if you are just beginning. You shouldn't be worried about learning one then having to learn the other, they are basically the same.
Also, Python is very good about being backwards compatible, so almost everything you would do in 3.1 would work in 3.2
There are noticeable differences between Python 2.x and 3.x, where there are some changes in syntax and the way things work. Even then, if you "learned" Python 2.7, you'd be able to figure out 3.2 in a matter of minutes once you understand the differences.

Related

Running python program using earlier version of python

I have python 2.7 installed. I want to use python 2.4 to run python code. Is it possible?
Either directly use the Python 2.4 interpreter to run it, or modify the programs she-bang line to point to the interpreter you wish to use.
Note that there's many things in common use in recent python (any/all, the 1 if 2 else 3 syntax, as well as major stdlib and language changes) that may cause your program to experience difficulties.
It's also worth noting that a lot of the common 3rd party modules require at least 2.5 and some of those are even dropping that and only guaranteeing 2.6+ compatibility.
You can install Python 2.4 as well. Any of the minor versions, 2.4, 2.5, 2.6, etc. can live side by side.
Code you write for 2.4 will also run on Python 2.7, albeit that you may hit some deprecation warnings. If you are using the 2.7 interpreter to write 2.4 code, you'll need to be careful that you don't use syntax and modules that have been added in newer Python versions.
To see what has been added, look at the What's new documentation; there is a document for each minor version:
What's new in Python 2.5
What's new in Python 2.6
What's new in Python 2.7
You specifically want to look for syntax changes and for new modules to avoid.
There are a few things that can bite you. Some syntactic changes have happened since 2.4, so you may get syntax errors. The standard library is bigger in 2.7, so you may have some things missing. The docs generally lists the version of python when things were added, and can be great help in making sure things will run on different python versions. Generally, syntax and libraries are forward compatible, so if you have to support 2.4, I would write using 2.4 and things should work with 2.7. The same is not true in reverse.

Python 2.7 or 3.3 for learning Django

I am interested in learning Python but I don't know which version I should chose. When I Googled, I got answers posted over a year ago. If I want to learn Django, which version will be useful and will get support?
Note that I know C, C++, Java and C#.
Django only has experimental support for Python 3, so you'll have to go with Python 2.7 for now.
First, a short comparison is It's Better than 2.7 and When should Python 3.3 become the default. However, remember that Python is in fact a script language and you can use C or C++ in doing modules with new capabilities.
I would recommend to start with python 2.7, it just more commonly used nowadays, and django is written in 2.7 AFAIK.
Apparently the answer you found still holds:
Should we use python 2.6 or 2.7 or 3.x?
If you already know several languages then learn both Python 2 and 3. The difference is small enough to allow many projects to support both versions using single (the same) source code.
For actual deployment you might prefer Python 2.7 if you need to use dependencies that are not ported to Python 3.

Python web development framework for python 3.1 user

I have been learning python for some time now. While starting this "learning python" endeavor I decided to learn the latest and greatest 3.1 version of python. I regret this decision now because I wanted to try my hands on some of the python web development frameworks & it looks like many of them do not support 3.1 yet & it looks like it might take them years to support the new version of Python especially Django and TurboGears. This is really disappointing. Therefore, SO users, do you have any recommendation for a web framework for me that runs on 3.1 and supports some of the modern (I guess I will never learn ;-)) web framework features like MVC/ORM/URL Routing/Caching etc.
How about trying Python2.7?, many of python 3.x features are backported to 2.7 recently, like OrderedDict, faster io modules, set comprehensions, dict comprehensions, etc...
And Python 2.7 is running no problem at all with django 1.2 trunk version in my experience.
In my opinion, learning new framework will take more time than switching from Python2.x to Python3.x, So choose one framework, and just keep using python 2.x and switch it to 3.x when the time come.
Like the others, I would suggest you start with Python 2.6.x -- Python 2.7 will be released this summer although you can grab an alpha or beta version today.
Although Python 3.x is backwards-incompatible with 2.x, Python syntax isn't going to be unrecognizable... pretty much everything is very similar to 2.x, but it's easy to break code when print changes from a statement to a function. So don't worry about Python 3 for now. As others have mentioned, you can get started right away with plenty of web frameworks that work in Python 2.x.
Also, just because of the numbering, do NOT be fooled in thinking that Python 2 is obsolete in any way nor can you follow the timeline serially. In other words, Python 2.7 will be newer than both Python 3.0 and 3.1. (3.2 won't be released until the end of this year.) Again, Python 2 has NOT been EOL'd -- both 2.x and 3.x are being developed actively.
The industrial world still runs on Python 2.x; the appearance of 3.x is a reminder that the next generation is here, and this is the time that all of the lower-level infrastructure and frameworks should begin their porting work so that we'll all eventually migrate.
If you want to find out more about the relationships between Python 2, Python 3, and the changes/differences between the two as well as the timeline and migration, you can check out this online article I wrote earlier this year:
"Python 3: The Evolution of a Programming Language"
http://www.informit.com/articles/article.aspx?p=1328795
I also gave a talk on this same subject at PyCon 2010 in February. You can access the video and the slide preso here:
http://us.pycon.org/2010/conference/schedule/event/29/
CherryPy 3.2 (still being worked on) will run on Python 3.x
Bottle can also run on Python 3.x after using 2to3 on it. Easy to do and it does work. However, Bottle is not a 'complete framework' but it is easy to use.
Edit:
I have used Bottle in Python 3.1, stackless python 3.1 to be specific, for a game that I am slowly working on. But at work, I am just using Python 2.6 And soon I will be using Webpy.
The site I work on is in PHP, but when I need to add a new feature, that I can easily separate from all the PHP code, I will do it in python. Even though I work with PHP almost everyday and use Python only a few times a month, I still can get things done faster in Python than PHP :)
Python 2.6 and Python 3.1 are really not all that different, I simply suggest you learn both, especially since both branches of Python are going to coexist for a while... so best to just learn the slight differences. The document "What's New in Python 3.0" explains most of the differences between 2.6 and 3.0.
There is ( are) actually a Django port to Py3k.
http://bitbucket.org/loewis/django-3k/
I can also remember quite good of having read a thread about a University project of porting Django to py3k, on the django-developers mailing-list, but I can't find the thread at the moment.
EDIT
Oh here it is:
https://bitbucket.org/fiji/django-3k/
The project is lead by students at the University of Toronto. :-)
ENDEDIT
Querying for something like "Django py3k port" brings up some useful results.
Also look at these URLs:
http://wiki.python.org/moin/PortingDjangoTo3k
http://groups.google.com/group/django-developers/browse_thread/thread/bf9d8808ee5aadb4/ccceb8901addceff?lnk=gst&q=django++port+py3k#ccceb8901addceff

python 2.5 dated?

I am just learning python on my ubuntu 8.04 machine which comes with
python 2.5 install. Is 2.5 too dated to continue learning? How much
of 2.5 version is still valid python code in the newer version?
Basically, python code, for the moment, will be divided into python 2.X code and python 3 code. Python 3 breaks many changes in the interest of cleaning up the language. The majority of code and libraries are written for 2.X in mind. It is probably best to learn one, and know what is different with the other. On an ubuntu machine, the python3 package will install Python 3, which can be run with the command python3, at least on my 8.10 install.
To answer your question, learning with 2.5 is fine, just keep in mind that 3 is a significant change, and learn the changes - ask yourself as you code, "how would this be different in 3, if at all?".
(As an aside, I do wish Ubuntu would upgrade to 2.6 though. It has a nice compatibility mode which tries and points out potential difficulties. But python is in such big use on a modern Linux distro, it can be a difficult change to make)
Here's an article describing 2.6 -> 3's changes
Python 2.5 will be fine for learning purposes. In the interest of learning you will probably want to look into the differences that python 3.0 has introduced, but I think most of the Python community is still using Python 2, as the majority of libraries haven't been ported over yet.
If your interested in 2.6 here is a blog post on compiling it on Hardy, there may even be a package for it somewhere out there on the internets.
Follow up, if there is a package I'm not finding it. Self compiling is pretty simple for most things, though I've never tried to compile Python.
I don't think it is 'too dated' to use, but there are some really nice features in python 2.6 that make it worth the update. This article will give you the details. As long as you have control of the machine, it is worth it.
I don't have any statistics but my impression is that Python 2.5 is the version most in use today. It is certainly not "dated" - I still use Python 2.5 and I expect that I will be using it for weeks or months yet to come.
If you have Python 2.6 available, though, I would suggest upgrading, as it's still fairly similar to Python 2.5 but will put you in better position for using Python 3.
Also, right now the 2.x branch is the most supported one, so I would also say that it's a good reason to start with that version.
And when the moment comes, you can always switch to Python 3.
Python 2.5 is fine. There are still plenty of people on Python 2.4 and 2.3.
One thing to keep in mind about python 2.6 is that some libraries may not work. Numpy comes to mind..

Is it required to learn Python 2.6 along with Python 3.0?

If I learn python 3.0 and code in it, will my code be still compatible with Python 2.6 (or 2.5 too!)?
Remarkably similar to:
If I'm Going to Learn Python, Should I Learn 2.x or Just Jump Into 3.0?
No, 3.x is largely incompatible with 2.x (that was actually a major motivation for doing it). In fact, you probably shouldn't be using 3.0 at all-- it's rather unusable at the moment, and is still mostly intended for library developers to port to it so that it can be usable.
Python 2.6 and Python 3.0 are very compatible with each other. There honestly aren't very many differences between the two. At this point, third-party library support is far better for the 2.x series (last I checked, a few libraries I use hadn't been updated from 2.5, but going from 2.5 to 2.6 is just a recompile, but 2.6 to 3.0 for C-level stuff is a real pain).
Just start learning 2.6. The infrastructure is there now, and there's plenty of help for when you finally want to move to 3.x. 2.x is not going away: there will be a 2.7 release at some point, so you're not going to be out of luck if you learn 2.6 now.
It would be easier to use 2.6 right now because most external libraries are not compatible with 3 yet.
NO. Python 3 code is backwards incompatible with 2.6. I recommend to begin with 2.6, because your code will be more useful.
In most cases it's not required anymore learn to Python 2 along with Python 3 for the following reasons.
Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained, and dedicating effort to learning it doesn't make sense anymore for most people. Also there may be problems installing some Python 2.7 packages that don't have any problems installing them in Python 3.
Python 3 is the best way to learn Python for the first time, because it's easier for beginners to understand than Python 2.

Categories