Are there any other uses for Python\'s \"from\" keyword aside from import
statements?
The following use
from __future__ import some_feature
is syntactically identical to an import statement but instead of importing a module, it changes the behavior of the interpreter in some fashion, depending on the value of some_feature
.
For example, from __future__ import with_statement
allows you to use Python's with
statement in Python 2.5, even though the with
statement wasn't added to the language until Python 2.6. Because it changes the parsing of source files, any __future__
imports must appear at the beginning of a source file.
See the __future__ statement documentation for more information.
See the __future__ module documentation for a list of possible __future__
imports and the Python versions they are available in.