Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python 2.x or 3.x [closed]

Since there is a python 3.x, why don't we use it?
Why do we still use 2.x?
What's the difference?

like image 638
magicshui Avatar asked Jul 15 '10 07:07

magicshui


4 Answers

Python 2.6 and 2.7 have been written to ease the transition to Python 3. It will take some more time to port the more complex packages (i.e. those with many dependencies, or libraries written in C).

So if you are starting new projects, and all the libraries you need are there, it makes sense to start with 3.1. One of the more welcome changes is the handling of Unicode strings by default - it will prevent a lot of bugs.

But if you were to port a complete ERP application, or anything big, from 2.6 to 3.x, it could be a bloodbath right now. The unicode changes for instance are the hardest to apply from 2.x -> 3.x, and the low level C APIs have changed a lot as well.

like image 117
Marco Mariani Avatar answered Oct 19 '22 19:10

Marco Mariani


Because 3.x isn't backwards compatible with 2.x and a lot of apps and libraries are written for the 2.x series. 3.x was their attempt at cleaning up all the crud that never should have been in Python in the first place.... and they had to make some breaking changes. Probably best to stick with 2.x for now, til 3.x gains a bit more popularity.

like image 35
mpen Avatar answered Oct 19 '22 19:10

mpen


The biggest differences are listed in the documentation of Python.

Hth. :)

like image 6
Anna SdG Avatar answered Oct 19 '22 19:10

Anna SdG


If you're writing a new app, and don't rely on libraries that have no 3.x support yet, I suggest you go for 3.x. Let's create some critical mass :)

Take a look at the python 3 documentation itself

like image 5
xtofl Avatar answered Oct 19 '22 18:10

xtofl