The __future__ module is used to enable features that are new but not yet turned on by default. Typically these features change an important aspect of the Python interpreter that could potentially break a lot of old code if they were turned on right away. Therefore, new features are introduced gradually—first as optional features and then as standard features in later releases.
Optional features are enabled by including a statement such as
from __future__ import featurename
at the top of a source file that uses the feature.
Currently, the following features have been defined:
Support for nested scopes in functions. First introduced in Python 2.1 and made the default behavior in Python 2.2.
Support for generators. ...