@@ -25,15 +25,13 @@ Features
2525.. image :: https://travis-ci.org/PythonCharmers/python-future.svg?branch=master
2626 :target: https://travis-ci.org/PythonCharmers/python-future
2727
28- - ``future.builtins `` package provides backports and remappings for 20
29- builtins with different semantics on Py3 versus Py2
28+ - ``future.builtins `` package (also available as ``builtins `` on Py2) provides
29+ backports and remappings for 20 builtins with different semantics on Py3
30+ versus Py2
3031
3132- ``future.standard_library ``, in conjunction with ``future.moves ``, provides
3233 support for importing standard library modules under their Python 3 names
3334
34- - ``future.backports `` package provides backports from the Py3.3
35- standard library
36-
3735- ``past.builtins `` package provides forward-ports of 19 Python 2 types and
3836 builtin functions. These can aid with per-module code migrations.
3937
@@ -65,8 +63,8 @@ these imports as it does on Python 3.3+:
6563.. code-block :: python
6664
6765 from __future__ import absolute_import, division, print_function
68- from future. builtins import (bytes , str , open , super , range ,
69- zip , round , input , int , pow , object )
66+ from builtins import (bytes , str , open , super , range ,
67+ zip , round , input , int , pow , object )
7068
7169 # Backported Py3 bytes object
7270 b = bytes (b ' ABCD' )
@@ -120,7 +118,7 @@ these imports as it does on Python 3.3+:
120118 assert isinstance (' blah' , str ) # only if unicode_literals is in effect
121119
122120 # Py3-style iterators written as new-style classes (subclasses of
123- # future.builtins.object ) are automatically backward compatible with Py2:
121+ # future.types.newobject ) are automatically backward compatible with Py2:
124122 class Upper (object ):
125123 def __init__ (self , iterable ):
126124 self ._iter = iter (iterable)
@@ -131,19 +129,25 @@ these imports as it does on Python 3.3+:
131129 assert list (Upper(' hello' )) == list (' HELLO' )
132130
133131
134- There is also support for renamed standard library modules in the form of import
135- hooks. The context-manager form works like this:
132+ There is also support for renamed standard library modules. The recommended
133+ interface works like this:
136134
137135.. code-block :: python
138136
137+ # Many Py3 module names are supported directly on both Py2.x and 3.x:
138+ from http.client import HttpConnection
139+ import html.parser
140+ import queue
141+ import xmlrpc.client
142+
143+ # Refactored modules with clashing names on Py2 and Py3 are supported
144+ # as follows:
139145 from future import standard_library
146+ standard_library.install_aliases()
140147
141- with standard_library.hooks():
142- from http.client import HttpConnection
143- from itertools import filterfalse
144- import html.parser
145- import queue
146- from urllib.request import urlopen
148+ # Then, as usual:
149+ from itertools import filterfalse
150+ from urllib.request import urlopen
147151
148152
149153 Automatic conversion to Py2/3-compatible code
@@ -190,9 +194,9 @@ into this code which runs on both Py2 and Py3:
190194.. code-block :: python
191195
192196 from __future__ import print_function
193- from future.builtins import input
194197 from future import standard_library
195- standard_library.install_hooks()
198+ standard_library.install_aliases()
199+ from builtins import input
196200 import queue
197201 from urllib.request import urlopen
198202
0 commit comments