http://python3wos.appspot.com/
The good news is that it's increasingly easy to write programs which run on both using newer idioms via __future__ backports, which is often both future proof and a way to write better code using newer language features which many people miss out on due to habit and old tutorials.
Lennart Regebro has a wonderful guide covering the changes and how to deal with them as painlessly as possible:
Not to mention the unicode implementation is broken. I was just talking to a Russian user (someone you'd assume would want unicode by default), and Python3 not operating on bytes by default is a mess. He can't move to Python3 due to how unicode is implemented.
print sys.getdefaultencoding() # ascii
print locale.getpreferredencoding() # cp1251
print sys.stdout.encoding # cp866
print sys.getfilesystemencoding() # mbcs
#~ print u"кодировочка!"
#~ print u"кодировочка!".encode('cp866')
#~ print unicode(u"кодировочка!", 'cp1251')
#~ os.rename ('b', u'б')
In most things in life, you'd always want the 'latest version', it would be a no-brainer. I wouldn't even bet on the transition to Python3 succeeding until it has- it's been 6 1/2 years already.
Use 2.7 and then move to 3.x when and if it ever makes sense. It won't be hard at all to switch as a user, that's not the problem.
Your code doesn't make any sense. Care to comment on what it means?
Guido didn't do us any favors with his migration strategy, but Python 3.4 is a substantially better and more modern language, so I would suggest developing on it (it's supported out of the box on Ubuntu 14.04 LTS, for example). It's true that app platform providers have not caught up yet, though.
Can you provide more details? The one thing that python3 did well is actually fixing the unicode/str mixup.
You posted some lines of code, but didn't tell exactly what's wrong with it.
> Python3 not operating on bytes by default is a mess
Why not just use the b'' prefix then and be explicit?
> can't move to Python3 due to how unicode is implemented
I'd like to see the bugs he raised against python 3 regarding this. There should be no difference in what you can and cannot do using python 2/3. I don't want to call BS on this, but... please provide some specific issues if you're claiming py3 is not usable.
I'm not arguing that it's not, but I don't how your examples support your point. Would you please explain how your examples show that "strings are unicode" is broken on Python 3?
FWIW, here's what I get:
Python 2:
>>> import sys, locale
>>> print(sys.getdefaultencoding())
ascii
>>> print(locale.getpreferredencoding())
UTF-8
>>> print(sys.stdout.encoding)
UTF-8
>>> print(sys.getfilesystemencoding())
utf-8
In Python 3, the only difference is: >>> print(sys.getdefaultencoding())
utf-8Is he running Python in, say, a Command Prompt window that's maintaining compatibility with a Russian-localized version of MS-DOS?
I can see how he can't move to Python 3, because Unicode support in his environment is basically impossible. That's a deeper problem than just Python. If he's been writing Python 2 code that deals with Russian text, it's probably producing mojibake when run on any machine but his own!
If you are going to do new greenfield development with no particular expectation of being tied to 2, 3 is probably better, But there's still some things you might wish to leverage that might make knowing 2, and how it differs from 3, useful.
The libraries are not that big of a problem, and since you plan to start with it, chances are you probably won't even have a need to use these libraries anyway (you don't have any existing codebase that relies on 2.x or these libraries).
The language is much cleaner in version 3 and from what I read and my personal experience it is much easier to make code written for version 3 work with 2.7 than the other way.
Writing in Python 3 feels way cleaner though. The objects super calls that didn't need to know their current class was great to use.
The choice only needs to be done when you know you will use a third party library that only supports Python 2. Some simple libraries can even be ported automatically using the 2to3 tool.
If you plan to just use pure Python (standard library), then give 3 a try.
Survival of the fittest?