Skip to content

Commit 1806ca7

Browse files
committed
More doc updates and improvements
1 parent 5a5267c commit 1806ca7

File tree

6 files changed

+91
-73
lines changed

6 files changed

+91
-73
lines changed

docs/conversion_limitations.rst

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,18 @@ Contributions to the ``lib2to3``-based fixers for ``futurize`` and
1717

1818
.. _futurize-limitations
1919
20-
Known limitations of ``futurize``
21-
---------------------------------
20+
Known limitations
21+
-----------------
2222

23-
``futurize`` doesn't currently make any of these changes automatically::
23+
``futurize`` doesn't currently make this change automatically::
2424

25-
1. A source encoding declaration line like::
26-
27-
# -*- coding:utf-8 -*-
28-
29-
is not kept at the top of a file. It must be moved manually back to line 1 to take effect.
30-
31-
2. Strings containing ``\U`` produce a ``SyntaxError`` on Python 3. An example is::
25+
1. Strings containing ``\U`` produce a ``SyntaxError`` on Python 3. An example is::
3226

3327
s = 'C:\Users'.
3428

3529
Python 2 expands this to ``s = 'C:\\Users'``, but Python 3 requires a raw
3630
prefix (``r'...'``). This also applies to multi-line strings (including
3731
multi-line docstrings).
3832

39-
33+
Also see the tests in ``future/tests/test_futurize.py`` marked
34+
``@expectedFailure`` or ``@skip`` for known limitations.

docs/credits.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Credits
2-
=======
1+
Credits, Copyright, Licensing
2+
=============================
33

44
:Author: Ed Schofield
55
:Sponsor: Python Charmers Pty Ltd, Australia, and Python Charmers Pte
@@ -22,12 +22,13 @@ Credits
2222
- ``past.translation`` is inspired by and borrows some code from
2323
Sanjay Vinip's ``uprefix`` module.
2424

25+
2526
.. _licence:
2627

27-
Licensing
28-
---------
28+
Licence
29+
-------
2930
The software is distributed under an MIT licence. The text is as follows
30-
(from LICENSE.txt)::
31+
(from ``LICENSE.txt``)::
3132

3233
Copyright (c) 2013-2014 Python Charmers Pty Ltd, Australia
3334

docs/faq.rst

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,8 @@ Who is this for?
77
1. People with existing or new Python 3 codebases who wish to provide
88
ongoing Python 2.6 / 2.7 support easily and with little maintenance burden.
99

10-
2. People who wish to simplify migration of their codebases to Python
11-
3.3+, module by module, without giving up Python 2 compatibility.
12-
13-
.. 3. People who would prefer to write clean, future-proof Python
14-
.. 3-compatible code, but who are required to write code that still runs
15-
.. on a Python 2 stack.
10+
2. People who wish to ease and accelerate migration of their Python 2 codebases
11+
to Python 3.3+, module by module, without giving up Python 2 compatibility.
1612

1713

1814
Why upgrade to Python 3?
@@ -29,9 +25,9 @@ Python 2.7 is the end of the Python 2 line. (See `PEP 404
2925
libraries are improving only in Python 3.x.
3026

3127
Python 3.x is a better language and better set of standard libraries than
32-
Python 2.x in almost every way. Python 3.x is cleaner, less warty, and easier to
28+
Python 2.x in many ways. Python 3.x is cleaner, less warty, and easier to
3329
learn than Python 2. It has better memory efficiency, easier Unicode handling,
34-
and powerful new features like function annotations and the `asyncio
30+
and powerful new features like the `asyncio
3531
<https://pypi.python.org/pypi/asyncio>`_ module.
3632

3733
.. Unicode handling is also much easier. For example, see `this page
@@ -43,8 +39,8 @@ and powerful new features like function annotations and the `asyncio
4339
Porting philosophy
4440
==================
4541

46-
Why use this approach?
47-
----------------------
42+
Why write Python 3-style code?
43+
------------------------------
4844

4945
Here are some quotes:
5046

@@ -72,8 +68,8 @@ Here are some quotes:
7268
Can't I just roll my own Py2/3 compatibility layer?
7369
---------------------------------------------------
7470

75-
Yes, but using ``future`` will probably lead to cleaner code with fewer
76-
bugs.
71+
Yes, but using ``python-future`` will probably be easier and lead to cleaner
72+
code with fewer bugs.
7773

7874
Consider this quote:
7975

@@ -88,28 +84,32 @@ Consider this quote:
8884

8985
``future`` also includes various Py2/3 compatibility tools in
9086
:mod:`future.utils` picked from large projects (including IPython,
91-
Django, Jinja2, Pandas), which should hopefully reduce the burden on
92-
every project to roll its own py3k compatibility wrapper module.
87+
Django, Jinja2, Pandas), which should reduce the burden on every project to
88+
roll its own py3k compatibility wrapper module.
89+
9390

91+
What inspired this project?
92+
---------------------------
9493

95-
How did the original need for this arise?
96-
-----------------------------------------
94+
In our Python training courses, we at `Python Charmers
95+
<http://pythoncharmers.com>`_ faced a dilemma: teach people Python 3, which was
96+
future-proof but not as useful to them today because of weaker 3rd-party
97+
package support, or teach people Python 2, which was more useful today but
98+
would require them to change their code and unlearn various habits soon. We
99+
searched for ways to avoid polluting the world with more deprecated code, but
100+
didn't find a good way.
97101

98-
In teaching Python, we at Python Charmers faced a dilemma: teach people
99-
Python 3, which was future-proof but not as useful to them today because
100-
of weaker 3rd-party package support, or teach people Python 2, which was
101-
more useful today but would require them to change their code and unlearn
102-
various habits soon. We searched for ways to avoid polluting the world
103-
with more deprecated code, but didn't find a good way.
102+
Also, in attempting to help with porting packages such as `scikit-learn
103+
<http://scikit-learn.org>`_ to Python 3, I (Ed) was dissatisfied with how much
104+
code cruft was necessary to introduce to support Python 2 and 3 from a single
105+
codebase (the preferred porting option). Since backward-compatibility with
106+
Python 2 may be necessary for at least the next 5 years, one of the promised
107+
benefits of Python 3 -- cleaner code with fewer of Python 2's warts -- was
108+
difficult to realize before in practice in a single codebase that supported
109+
both platforms.
104110

105-
Also, in attempting to help with porting packages such as
106-
``scikit-learn`` to Python 3, I was dissatisfied with how much code cruft
107-
was necessary to introduce to support Python 2 and 3 from a single
108-
codebase (the preferred porting option). Since backward-compatibility
109-
with Python 2 may be necessary for at least the next 5 years, one of the
110-
promised benefits of Python 3 -- cleaner code with fewer of Python 2's
111-
warts -- was difficult to realize before in practice in a single codebase
112-
that supported both platforms.
111+
The goal is to accelerate the uptake of Python 3 and help the strong Python
112+
community to remain united around a single version of the language.
113113

114114

115115
Maturity
@@ -123,8 +123,8 @@ Is it tested?
123123
currently being used to help with porting 800,000 lines of Python 2 code in
124124
`Sage <http://sagemath.org>`_ to Python 2/3.
125125

126-
Currently ``future`` has 800+ unit tests. Many of these are straight from the
127-
Python 3.3 test suite.
126+
Currently ``python-future`` has 800+ unit tests. Many of these are straight
127+
from the Python 3.3 test suite.
128128

129129
In general, the ``future`` package itself is in good shape, whereas the
130130
``futurize`` script for automatic porting is incomplete and imperfect.
@@ -151,11 +151,11 @@ version 2.0.
151151
modules under ``future/standard_library/``.
152152
153153

154-
Relationship between ``future`` and other compatibility tools
155-
=============================================================
154+
Relationship between python-future and other compatibility tools
155+
================================================================
156156

157-
How does this relate to ``2to3`` and ``lib2to3``?
158-
-------------------------------------------------
157+
How does this relate to ``2to3``?
158+
---------------------------------
159159

160160
``2to3`` is a powerful and flexible tool that can produce different
161161
styles of Python 3 code. It is, however, primarily designed for one-way
@@ -206,31 +206,33 @@ auto-generated Python 3 code. (See `this talk
206206
What is the relationship between ``future`` and ``six``?
207207
--------------------------------------------------------
208208

209-
``future`` is a higher-level compatibility layer than ``six`` that
209+
``python-future`` is a higher-level compatibility layer than ``six`` that
210210
includes more backported functionality from Python 3 and supports cleaner
211211
code but requires more modern Python versions to run.
212212

213-
``future`` and ``six`` share the same goal of making it possible to write
213+
``python-future`` and ``six`` share the same goal of making it possible to write
214214
a single-source codebase that works on both Python 2 and Python 3.
215-
``future`` has the further goal of allowing standard Py3 code to run with
215+
``python-future`` has the further goal of allowing standard Py3 code to run with
216216
almost no modification on both Py3 and Py2. ``future`` provides a more
217217
complete set of support for Python 3's features, including backports of
218218
Python 3 builtins such as the ``bytes`` object (which is very different
219219
to Python 2's ``str`` object) and several standard library modules.
220220

221-
``future`` supports only Python 2.6+ and Python 3.3+, whereas ``six``
221+
``python-future`` supports only Python 2.6+ and Python 3.3+, whereas ``six``
222222
supports all versions of Python from 2.4 onwards. (See
223223
:ref:`supported-versions`.) If you must support older Python versions,
224224
``six`` will be esssential for you. However, beware that maintaining
225225
single-source compatibility with older Python versions is ugly and `not
226226
fun <http://lucumr.pocoo.org/2013/5/21/porting-to-python-3-redux/>`_.
227227

228-
If you can drop support for older Python versions, ``future`` leverages
228+
If you can drop support for older Python versions, ``python-future`` leverages
229229
some important features introduced into Python 2.6 and 2.7, such as
230-
import hooks, to allow you to write more idiomatic, maintainable code.
230+
import hooks, and a comprehensive and well-tested set of backported
231+
functionality, to allow you to write more idiomatic, maintainable code with
232+
fewer compatibility hacks.
231233

232234

233-
What is the relationship between this project and ``python-modernize``?
235+
What is the relationship between ``python-future`` and ``python-modernize``?
234236
-----------------------------------------------------------------------
235237

236238
``python-future`` contains, in addition to the ``future`` compatibility
@@ -240,7 +242,7 @@ in intent and design. Both are based heavily on ``2to3``.
240242
Whereas ``python-modernize`` converts Py2 code into a common subset of
241243
Python 2 and 3, with ``six`` as a run-time dependency, ``futurize``
242244
converts either Py2 or Py3 code into (almost) standard Python 3 code,
243-
with ``future`` as a run-time dependency.
245+
with ``future`` as a run-time dependency.
244246

245247
Because ``future`` provides more backported Py3 behaviours from ``six``,
246248
the code resulting from ``futurize`` is more likely to work
@@ -253,7 +255,7 @@ Platform and version support
253255

254256
.. _supported-versions:
255257

256-
Which versions of Python does ``future`` support?
258+
Which versions of Python does ``python-future`` support?
257259
-------------------------------------------------
258260

259261
Python 2.6, 2.7, and 3.3+ only.

docs/imports.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ standard feature of Python, see the following docs:
2727
These are all available in Python 2.6 and up, and enabled by default in Python 3.x.
2828

2929

30-
.. _star-imports:
30+
future.builtins imports
31+
-----------------------
3132

32-
future imports
33-
--------------
33+
.. _star-imports:
3434

3535
Implicit imports
3636
~~~~~~~~~~~~~~~~
@@ -85,6 +85,7 @@ To understand the details of the backported builtins on Python 2, see the
8585
docs for these modules. Please note that this internal API is evolving and may
8686
not be stable between different versions of ``future``.
8787

88+
For more information on what the backported types provide, see :ref:`what-else`.
8889

8990
.. < Section about past.translation is included here >
9091

docs/reference.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#############
2-
API Reference
3-
#############
1+
API Reference (in progress)
2+
***************************
43

54
**NOTE: This page is still a work in progress... We need to go through our
65
docstrings and make them sphinx-compliant, and figure out how to improve

docs/standard_library_imports.rst

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ There are currently four interfaces to the reorganized standard library.
1313

1414
Context-manager interface
1515
-------------------------
16-
The first interface is via a context-manager called ``hooks``::
16+
The recommended interface is via a context-manager called ``hooks``::
1717

1818
from future import standard_library
1919
with standard_library.hooks():
@@ -48,13 +48,12 @@ support syntax like this::
4848

4949
from future.moves import http.client
5050

51-
One workaround (which ``six.moves`` also requires) is to replace the dot with
52-
an underscore::
51+
One workaround is to replace the dot with an underscore::
5352

5453
import future.moves.http.client as http_client
5554

56-
``import_`` and from_import functions
57-
-----------------------------------------
55+
import_ and from_import functions
56+
---------------------------------
5857

5958
A third option, which also works with two-level imports, is to use the
6059
``import_`` and ``from_import`` functions from ``future.standard_library`` as
@@ -68,7 +67,7 @@ follows::
6867
urlopen, urlsplit = from_import('urllib.request', 'urlopen', 'urlsplit')
6968

7069
install_hooks() call
71-
------------------------
70+
--------------------
7271

7372
The fourth interface to the reorganized standard library is via an
7473
explicit call to ``install_hooks``::
@@ -146,6 +145,27 @@ The modules available via ``future.moves`` are::
146145

147146
.. Disabled: import test.support
148147
148+
149+
Comparing future.moves and six.moves
150+
------------------------------------
151+
152+
``future.moves`` and ``six.moves`` provide a similar Python 3-style
153+
interface to the native standard library module definitions.
154+
155+
The major difference is that the ``future.moves`` package is a real Python package
156+
(``future/moves/__init__.py``) with real modules provided as ``.py`` files, whereas
157+
``six.moves`` constructs fake ``_LazyModule`` module objects within the Python
158+
code and injects them into the ``sys.modules`` cache.
159+
160+
The advantage of ``six.moves`` is that the code fits in a single module that can be
161+
copied into a project that seeks to eliminate external dependencies.
162+
163+
The advantage of ``future.moves`` is that it is likely to be more robust in the
164+
face of magic like Django's auto-reloader and tools like ``py2exe`` and
165+
``cx_freeze``. See issues #51, #53, #56, and #63 in the ``six`` project for
166+
more detail of bugs related to the ``six.moves`` approach.
167+
168+
149169
Backports
150170
---------
151171

0 commit comments

Comments
 (0)