Why Python 3?

Chris Angelico rosuav at gmail.com
Sat Apr 19 09:42:47 EDT 2014


On Sat, Apr 19, 2014 at 11:26 PM, Roy Smith <roy at panix.com> wrote:
> 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.

Conversely, committing to Py2 now eliminates from possible future use
all modules which support only Py3. Is there strong evidence that one
of those groups is larger than the other?

>> 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.

Red Hat? :) Though that's likely to be the last bastion of ancient
Python out there, soon. Debian Squeeze (oldstable) ships with 2.6, so
if you aim for 2.6+, you should catch all the distros that derive from
Debian (the current Debian stable, Wheezy, ships with 2.7). But Red
Hat will be supporting older Pythons for a good while.

>> 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.

Right. It's not the magic line that fixes everything; if it were,
Python 3 wouldn't be a big deal at all. Go Py3 if you can, but if you
can't, at least make your double-quoted strings Unicode strings, and
then you have a chance to find problems.

ChrisA



More information about the Python-list mailing list