How does the __future__ module work in Python 2.7?
Question: In Python 2.7 using the `__future__` module and the `print_function` you can
use the python 3.X print function. My question is, how did the developers of
Python know what was coming in the future releases of Python? Or was this
module added to Python 2.7 after it was released? Here is the code I am
talking about:

    
    
    from __future__ import print_function
    print("Hello world!")
    


Answer: The [`__future__`](https://docs.python.org/3.5/library/__future__.html) module
was introduced in Python 2.1 in order to have access to upcoming
features/functions which will lead to incompatibilities with the current
implementation and is extended with each version if needed.

So the module gives the possibility to use those incompatible functions of
future versions in earlier versions. So you can make use of the upcoming
advantages of those functions.

There are three main reasons for that module as stated in the docs:

> `__future__` is a real module, and serves three purposes:
>
>   * To avoid confusing existing tools that analyze import statements and
> expect to find the modules they’re importing.
>   * To ensure that future statements run under releases prior to 2.1 at
> least yield runtime exceptions (the import of `__future__` will fail,
> because there was no module of that name prior to 2.1).
>   * To document when incompatible changes were introduced, and when they
> will be — or were — made mandatory. This is a form of executable
> documentation, and can be inspected programmatically via importing
> `__future__` and examining its contents.
>

