[Python-checkins] r81411 - python/branches/release26-maint/Doc/library/2to3.rst

benjamin.peterson python-checkins at python.org
Fri May 21 22:46:53 CEST 2010


Author: benjamin.peterson
Date: Fri May 21 22:46:53 2010
New Revision: 81411

Log:
update 2to3 docs

Modified:
   python/branches/release26-maint/Doc/library/2to3.rst

Modified: python/branches/release26-maint/Doc/library/2to3.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/2to3.rst	(original)
+++ python/branches/release26-maint/Doc/library/2to3.rst	Fri May 21 22:46:53 2010
@@ -86,13 +86,21 @@
 The :option:`-v` option enables output of more information on the translation
 process.
 
+Since some print statements can be parsed as function calls or statements, 2to3
+cannot always read files containing the print function.  When 2to3 detects the
+presence of the ``from __future__ import print_function`` compiler directive, it
+modifies its internal grammar to interpert :func:`print` as a function.  This
+change can also be enabled manually with the :option:`-p` flag.  Use
+:option:`-p` to run fixers on code that already has had its print statements
+converted.
+
 
 .. _2to3-fixers:
 
 Fixers
 ------
 
-Each step of tranforming code is encapsulated in a fixer.  The command ``2to3
+Each step of transforming code is encapsulated in a fixer.  The command ``2to3
 -l`` lists them.  As :ref:`documented above <2to3-using>`, each can be turned on
 and off individually.  They are described here in more detail.
 
@@ -114,7 +122,8 @@
 
 .. 2to3fixer:: callable
 
-   Converts ``callable(x)`` to ``hasattr(x, "__call__")``.
+   Converts ``callable(x)`` to ``isinstance(x, collections.Callable)``, adding
+   an import to :mod:`collections` if needed.
 
 .. 2to3fixer:: dict
 
@@ -167,11 +176,11 @@
 
 .. 2to3fixer:: idioms
 
-   This optional fixer preforms several transformations that make Python code
-   more idiomatic.  Type comparisions like ``type(x) is SomeClass`` and
+   This optional fixer performs several transformations that make Python code
+   more idiomatic.  Type comparisons like ``type(x) is SomeClass`` and
    ``type(x) == SomeClass`` are converted to ``isinstance(x, SomeClass)``.
    ``while 1`` becomes ``while True``.  This fixer also tries to make use of
-   :func:`sorted` in appropiate places.  For example, this block ::
+   :func:`sorted` in appropriate places.  For example, this block ::
 
        L = list(some_iterable)
        L.sort()


More information about the Python-checkins mailing list