running python 2 vs 3
ned at nedbatchelder.com
Thu Mar 20 21:53:25 CET 2014
On 3/20/14 4:42 PM, Marko Rauhamaa wrote:
> Ned Batchelder <ned at nedbatchelder.com>:
>> Plenty of people have adopted a dual-support strategy, with one code
>> base that supports both Python 2 and Python 3. The six module can help
>> a great deal with this.
> I wonder how easy the resulting code is to the eyes and how easy it is
> for the casual maintainer to accidentally break the delicate balance. In
> a word, I wouldn't go there. Stay with Python2 as long as you must and
> then, migrate and leave it behind.
This is fine advice for applications, but tools, libraries, and
frameworks may want to support more than one version at the same time.
It's an extreme case, but the latest released version of coverage.py
supports Python 2.3 through 3.3 with one code base. To do it, there's a
compatibility layer (akin to six). Then you stay away from features
that aren't available on all versions. In a few places, you might need
to have version checks, and the code can get a little idiomatic to
continue to work.
It's a tradeoff: you have to decide for yourself whether the effort is
worth the benefit. I was glad to be able to drop support for 2.3, 2.4,
and 2.5, and now only support 2.6-3.4 in coverage.py.
Ned Batchelder, http://nedbatchelder.com
More information about the Python-list