The __future__
module is built-in to Python, and is provided to allow programmers to make advance use of feature sets which are not yet regarded as complete. Although some of the features (e.g., from __future__ import print_function
) are provided specifically to assist with porting Python 2 programs to Python 3, it is also used to give early access to advance features of any release.
__future__
is unique, in that some imports such as the print_function
can actually change the syntax accepted by the interpreter.
python-future
is a third-party module, one of several to provide compatibility features. You could also take a look at six
, though it's now somewhat long in the tooth, and python-modernize
. It's quite likely you will find that you need to use both __future__
and future
together.
Another strategy you may not have considered is to convert your source to Python 2 that can be translated automatically by the 2to3
utility. There is also a lib3to2
that will translate the other way, though I have no experience with it.