The module __future__
really is a bit magical. It would be more necessary to see the from __future__ import
as a statement for the Python compiler instead of a import
typical.
The raison d'être of from __future__ import
is to provide features planned for future versions of Python but that may not be the default behavior of the language yet to preserve compatibility with existing Programs.
For example, in Python 2 the print
is a command that is called without parentheses:
print "Oi Mundo"
Already in Python 3, the print
became a normal function, called with parentheses
print("Oi Mundo")
To facilitate this transition, from Python 2.6 print as a function is an optional feature. The default in Python 2.6 is print to be a command but if you use from __future__ import print_function
print becomes a function.
For more information, see PEP 236, who proposed the __future__
, and the section on Future statements in the official documentation.
@mgibsonbr I also think he meant "No parentheses"
– Wallace Maxters
ops! s/spaces/parentheses/
– hugomg