Writing Python 2.7 code that is as close to Python 3.x syntax as possible

Many modules these days get rewritten in a way that allows execution on both Python 2 and Python 3. This turns out to be not very hard at all, and in the future it will be very easy to just drop Python 2 support.

Take a look at the six module that helps with this task, encapsulating many of the differences in a convenient way:

Six provides simple utilities for
wrapping over differences between
Python 2 and Python 3.

Its website (and of course, code) lists a lot of ways to make this possible.

Leave a Comment