Python 2 or 3?
Way way back in 2009, I decided to look into Python. For one reason or another that didn't really go any further than playing about with Fabric but I've decided once again that it is a language I'd really like to get more involved in. However when looking to start a new project in Python, there is one very big question: Python 2 or 3? Which should I focus on and use?
At the time of writing, the two stable versions of Python are 2.7.3 and 3.2.3 (with 3.3.0 in beta and on course for a late-August release). As the previous sentence alludes to – and the Python wiki clarifies – Python 3 is the "present and future" of Python and development of the 2.x branch is no longer continuing. That said, the reality is that there are still many libraries and frameworks not yet ready for the transition to 3, and 2.x is going to be supported and be bug-fixed for quite some time yet.
In an Ideal World...
Ideally everything would already be compatible with Python 3 and it would be the default Python installed on modern systems. The choice would be obvious and I'd not be writing this at all! However since it is so new, this is not yet the case. The first version of Python 3.0 came out in December 2008, and since then has slowly but steadily increased in popularity, but the 2.x branch has been around since 2000 – and it should be noted that 2.0 did not break backwards-compatibility like 3.0 did, and Python 1.0 has been around since early 1994.
Work on porting to 3.x or adding 3.x compatibility to various libraries and frameworks continues but it is not a small job, particularly when there could be many dependancies which also need to add 3.x compatibility first. Right now though, there are loads of very popular packages which are not ready.
One of the main things I'd like to get into is Django, and I certainly plan to spend some time looking at Flask as well. Sadly right now neither of these support Python 3, although Django will have experimental Python 3 support in 1.5 which is expected later this year. This pretty much makes the decision for me: right now, Python 2 or nothing.
Despite this, Python 3 is clearly the future and I always like the future. My plan is to stick with Python 2 for the time being, since that is the only choice and as soon as it becomes feasible, look at moving over to Python 3 where there is nothing stopping me. I'm hoping Django 1.5 turns out to be the tipping point for me. Until then, I am going to write my Python code bearing in mind the various pieces of advice (see related links) for ensuring the Python code is forwards-compatible as much as is reasonable – without going to extraordinary lengths because I'll inevitably end up doing some work during the porting process either way.
In addition, I will be keeping an eye on the more forward-looking Linux distros such as Ubuntu and Fedora to see if and when they decide to flip over to Python 3 as the default. When that happens, I think it will signal the beginning of the end for Python 2, and that Python 3 is established enough to be the one true Python. Arch has already made that jump and at the time of writing, the
python package is version 3.2.3, and to install Python 2, there is a