Why Python 3?

Roy Smith roy at panix.com
Sat Apr 19 09:26:53 EDT 2014


Chris Angelico <rosuav at gmail.com> wrote:

> I strongly recommend going for Python 3 unless something actually
> stops you from doing so.

One of the problems is you don't know in advance if something is going 
to stop you.  By committing to P3 now, you are eliminating from possible 
future use, all of those third-party modules which only support P2.  And 
you don't know which of those you'll need until you sometime in the 
future.

It's rare to find a modern, actively maintained module which doesn't 
either support P3 already, or at least has that on its roadmap, but 
there's a lot of old stuff out there which is still very useful.

> If you absolutely must use Python 2, try to
> aim for a minimum of 2.6 or 2.7

That I absolutely agree with.  Unless I had some specific legacy use 
case I needed to continue to support, I wouldn't waste any time worrying 
about 2.5 support, and we're quickly reaching the point where the same 
can be said about 2.6.

> and start your program with this line:
> 
> from __future__ import print_function, unicode_literals, division

That seems reasonable, but be prepared for possible unicode issues.  
There is code out there in third party modules which makes 
unicode-unfriendly assumptions about strings.  For example:

https://github.com/brandon-rhodes/pyephem/issues/35

I'm not saying don't use unicode_literals (we do), just we aware that 
you might have to explicitly cast things to str() once in a while.



More information about the Python-list mailing list