Enabling Future Features

Starting in Python 2.1, new language features that affect compatibility with older versions of Python may be disabled when they first appear in a release. To enable these features, the statement from _ _ future_ _ import feature can be used. For example:

# Enable nested scopes in Python 2.1 
from __ future __ import nested_scopes 

When used, this statement should appear as the first statement of a module or program. Furthermore, the intent of the _ _ future_ _ module is to introduce features that will eventually be a standard part of the Python language (in which case, the use of _ _ future_ _ will not be required).

Get Python Essential Reference, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.