[Python-checkins] r83741 - python/branches/py3k/Doc/library/2to3.rst

alexandre.vassalotti python-checkins at python.org
Thu Aug 5 09:12:19 CEST 2010


Author: alexandre.vassalotti
Date: Thu Aug  5 09:12:18 2010
New Revision: 83741

Log:
Issue 5077: Add documentation for operator fixer.

Patch by Meador Inge.


Modified:
   python/branches/py3k/Doc/library/2to3.rst

Modified: python/branches/py3k/Doc/library/2to3.rst
==============================================================================
--- python/branches/py3k/Doc/library/2to3.rst	(original)
+++ python/branches/py3k/Doc/library/2to3.rst	Thu Aug  5 09:12:18 2010
@@ -267,6 +267,25 @@
 
    Converts octal literals into the new syntax.
 
+.. 2to3fixer:: operator
+
+   Converts calls to various functions in the :mod:`operator` module to other,
+   but equivalent, function calls.  When needed, the appropriate ``import``
+   statements are added, e.g. ``import collections``.  The following mapping
+   are made:
+
+   ==================================  ==========================================
+   From                                To
+   ==================================  ==========================================
+   ``operator.isCallable(obj)``        ``hasattr(obj, '__call__')``
+   ``operator.sequenceIncludes(obj)``  ``operator.contains(obj)``
+   ``operator.isSequenceType(obj)``    ``isinstance(obj, collections.Sequence)``
+   ``operator.isMappingType(obj)``     ``isinstance(obj, collections.Mapping)``
+   ``operator.isNumberType(obj)``      ``isinstance(obj, numbers.Number)``
+   ``operator.repeat(obj, n)``         ``operator.mul(obj, n)``
+   ``operator.irepeat(obj, n)``        ``operator.imul(obj, n)``
+   ==================================  ==========================================
+
 .. 2to3fixer:: paren
 
    Add extra parenthesis where they are required in list comprehensions.  For


More information about the Python-checkins mailing list