25

The version of python which I am using is 2.6, and there is a 2.7 and 3.x. Usually I use python for some trivial program/snippet. I realize there are some major difference between 2.x and 3.x. I would really like to know, if I am going to make a bigger project with python, which version of python should I use?

Should I upgrade to 2.7, or go to 3.x or stay with 2.6?

The decision should be based on these terms:

  1. Number of user in the internet as a community. More users mean more open-source package and help from them.

  2. Functionality.

  3. Support from official development team.

  4. Compatibility for existing module/package.

Thanks!

5
  • 5
    Can someone point out any beneficial changes made by python 3.x? Commented Aug 23, 2011 at 4:39
  • 1
    You mention that you know that compatibility with existing modules is an issue, but you don't tell us what existing modules your code relies on. This question is pretty much unanswerable.
    – Wooble
    Commented Aug 23, 2011 at 11:36
  • 2
    off topic; recommendations AND gorilla vs shark in one question wow!
    – user7519
    Commented Jul 15, 2012 at 8:05
  • 3
    This question and it's answers will only be useful for a small window of time. What makes sense now might not make much sense a year from now as 3.x becomes more mature. Commented Aug 21, 2012 at 16:37
  • Noting that (a) the question is still relevant in 2014 (e.g. RobotFramework does not work with Python 3) and (b) closing this question keeps this page stale because -- even though it comes up high on google search results -- new answers can't be posted.
    – Bob Stein
    Commented Aug 16, 2014 at 14:43

7 Answers 7

27

I would suggest Python 2.7 myself. It's the latest release in the Python 2.x series. Most of the Python modules are made to work with the Python 2.x. There is a movement to try and move to Python 3, but any of the Python 3 modules are written for both 2 and 3. Remember to not use old features which are not available in Python 3, so that you can just 2to3 your code to make it run on Python 3.

If you go with Python 3, you're one of the early adopters and you will likely have to tell others to download Python 3 (a lot of computers will just have Python 2). On the other hand, new features are only going to come to Python 3. Python 2 is permanently in maintenence. So I would not suggest still using Python 2 in 10 years.

If you want to keep an eye on Python packages and their compatibility with Python 3, you can keep an eye on this site: http://python3wos.appspot.com/

5
  • django doesn't support 3.x? So user familiar with django just can't use 3.x? Commented Aug 23, 2011 at 4:13
  • hey normally when a new version gets released it means it is better then the earlier one. And why python is getting released in 2.x series and another in 3.x series? What is the actual difference in them.
    – ASKN
    Commented Aug 23, 2011 at 4:31
  • 4
    Python 3 made some changes to the language that are beneficial, but they are not backwards compatible with some of the features in Python 2. So some things were removed and some added (and the removed things make them not compatible).
    – jsternberg
    Commented Aug 23, 2011 at 4:35
  • +1 for 2.7, best ratio of compatibility (at least for the libraries I use) until 3 is more widespread
    – wildpeaks
    Commented Jul 15, 2012 at 10:22
  • @Ashinkn The changes can be found here docs.python.org/3.0/whatsnew/3.0.html. The major compatibility-breaking change being the switch from using Unicode (as opposed to ASCII) as the default string type. Where people used strings as byte[] before there is a new bytearray type that is used instead. Also, any 2x strings explicitly defined as unicode need to be changed to regular strings. Commented Feb 27, 2013 at 20:31
19

My opinion is we need to start getting people over to Python 3 and if there are libraries that are not compatible with Python 3, we need to start making that not the case.

Python 3 is the future of the language, and the more code we write using it, the better.

1
  • What we need is a single interpreter that is compatible with both versions of python and can intelligently parse them. That is, said interpreter would compile both python2 and python3 into the same bytecode so that they are compatible, making it possible to use python3 with a python2 library. If C, C++, and Java can do it, then so can Python. Commented Oct 14, 2016 at 22:48
4

Django now "experimentally" supports Python 3.2+ as you can see from their posts here.

Given that, and the fact that Python 3.x is the future of the language, I would say Python 3 is best now.

2

For each project check if all libraries required for a project already got 3.x python support then use python 3.x because it's future and that's last official stable version.

Else use whatever you need to use for library compatibility.

2

It doesn't really matter whether you use Python 2.7 or Python 3 If you do not use old features in Python 2.7, you can just 2to3 your code to make it run on Python 3.

0

I was in the same boat previously and this is what I found. Python 2.6, 2.7, and 3.2 can be installed side-by-side using MacPorts and can easily be switched. (I am a Mac user). Look for alternatives to Macports for your platform.

0

Until a bridge is developed intrinsically within 3.x to allow the transparent use of 2.7 packages a move is fraught with peril because the language is really all about what has been contributed to it. Formal considerations and purity are negligible in comparison. Such a transparent bridge isn't likely to happen out of sheer pedantic stubbornness and disregard for the user base.

1
  • Such a transparent bridge is unattainable. The 2to3 and six packages provide ample bridging, but are far from transparent. Commented Nov 24, 2012 at 11:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.