@@ -11,7 +11,7 @@ yet been ported to Python 3.
1111
1212It is designed to be used as follows::
1313
14- from __future__ import (division, absolute_import ,
14+ from __future__ import (absolute_import, division ,
1515 print_function, unicode_literals)
1616 from future import standard_library
1717 from future.builtins import *
@@ -99,11 +99,11 @@ future::
9999
100100Utilities
101101---------
102- ``future `` also provides some useful functions and decorators in the
103- to ease backward compatibility with Py2 in the ``future.utils `` module.
104- These are a selection of the most useful functions from ``six `` and
105- various home-grown Py2/3 compatibility modules from prominent Python
106- projects (Jinja2, Pandas, Django) .
102+ ``future `` also provides some useful functions and decorators to ease backward
103+ compatibility with Py2 in the ``future.utils `` module. These are a selection
104+ of the most useful functions from ``six `` and various home-grown Py2/3
105+ compatibility modules from various Python projects, such as Jinja2, Pandas,
106+ IPython, and Django.
107107
108108Examples::
109109
@@ -124,8 +124,8 @@ Examples::
124124
125125
126126 # Iterators on Py3 require a __next__() method, whereas on Py2 this
127- is called next(). This decorator allows Py3-style iterators to work
128- identically on Py2:
127+ # is called next(). This decorator allows Py3-style iterators to work
128+ # identically on Py2:
129129
130130 @implements_iterator
131131 class Upper(object):
@@ -167,8 +167,8 @@ See the docstrings for each of these modules for more info::
167167Automatic conversion
168168====================
169169
170- There is a script included called ``futurize `` to aid in making either
171- Python 2 code or Python 3 code compatible with both platforms using the
170+ There is an experimental script included called ``futurize `` to aid in making
171+ either Python 2 code or Python 3 code compatible with both platforms using the
172172``future `` module. It is based on 2to3 and uses fixers from ``lib2to3 ``,
173173``lib3to2 ``, and ``python-modernize ``.
174174
@@ -317,13 +317,16 @@ FAQ
317317 easier upgrade path to Python 3.
318318
319319
320- :Q: Are there any example of Python 2 packages ported to Python 3 using ``future `` and ``futurize ``?
320+ :Q: Are there any example of Python 2 packages ported to Python 3 using
321+ ``future `` and ``futurize ``?
321322
322323:A: Yes, an example is the port of ``xlwt ``, available here::
323- ``xlwt `` and ``iso8601 ``, available here::
324324
325325- https://github.com/python-excel/xlwt/pull/32
326326
327+ The code also contains backports for several Py3 standard library modules
328+ under ``future/standard_library/backports/ ``.
329+
327330
328331Other compatibility tools
329332-------------------------
@@ -336,9 +339,9 @@ Other compatibility tools
336339 one-way porting efforts, for projects that can leave behind Python 2
337340 support.
338341
339- The example at the top of the 2to3 docs
340- (http://docs.python.org/2/library/2to3.html) illustrates this point .
341- After transformation, ``example.py `` looks like this::
342+ The example at the top of the `` 2to3 `` docs
343+ (http://docs.python.org/2/library/2to3.html) demonstrates this.
344+ After transformation by `` 2to3 `` , ``example.py `` looks like this::
342345
343346 def greet(name):
344347 print("Hello, {0}!".format(name))
@@ -349,7 +352,8 @@ Other compatibility tools
349352 This is Python 3 code that, although syntactically valid on Python 2,
350353 is semantically incorrect. On Python 2, it raises an exception for
351354 most inputs; worse, it allows arbitrary code execution by the user
352- for specially crafted inputs.
355+ for specially crafted inputs because of the ``eval() `` executed by Python
356+ 2's ``input() `` function.
353357
354358 This is not an isolated example; almost every output of ``2to3 `` will
355359 need modification to provide backward compatibility with Python 2.
@@ -365,10 +369,10 @@ Other compatibility tools
365369 convert to Python 3 in the setup script?
366370
367371:A: Yes, this is possible, and was originally the approach recommended by
368- Python's core developers, but has big drawbacks.
372+ Python's core developers, but has some large drawbacks.
369373
370374 First, your actual working codebase will be stuck with only Python
371- 2's features ( and its warts) for as long as you need to retain Python
375+ 2's features, and its warts, for as long as you need to retain Python
372376 2 compatibility. This may be at least 5 years for many projects.
373377
374378 This approach also carries the significant disadvantage that you
@@ -384,11 +388,10 @@ Other compatibility tools
384388
385389 They share the same goal of making it possible to write a
386390 single-source codebase that works on both Python 2 and Python 3
387- without modification. ``future `` makes it easier to write standard
388- Python 3 code that is a cleaner interface that runs on both
389- platforms, and ``future `` provides a more complete set of support for
390- Python 3's features (and restores a few Py2 features removed from
391- Python 3).
391+ without modification. ``future `` provides a more complete set of support
392+ for Python 3's features and a cleaner interface (supporting standard Py3
393+ code). ``future `` also restores a few Py2 features that were removed from
394+ Python 3.
392395
393396 Codebases that use ``six `` directly tend to be mixtures of
394397 Python 2 code, Python 3 code, and ``six ``-specific wrapper
@@ -472,9 +475,9 @@ Other compatibility tools
472475 unlearn various habits soon. We searched for ways to avoid polluting the
473476 world with more deprecated code, but didn't find a good way.
474477
475- Also, in attempting to port ``scikit-learn `` to Python 3, I (Ed) was
476- dissatisfied with how much code cruft was necessary to introduce to
477- support Python 2 and 3 from a single codebase (the preferred porting
478+ Also, in attempting to port packages such as ``scikit-learn `` to Python 3,
479+ I (Ed) was dissatisfied with how much code cruft was necessary to introduce
480+ to support Python 2 and 3 from a single codebase (the preferred porting
478481 option).
479482
480483 Since backward-compatibility with Python 2 may be necessary
0 commit comments