summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorAlexandre Vassalotti <alexandre@peadrop.com>2010-08-05 07:12:18 (GMT)
committerAlexandre Vassalotti <alexandre@peadrop.com>2010-08-05 07:12:18 (GMT)
commitae7801813c56464e08f7a29c917aa2bc1326831b (patch)
tree0e4fb0aebd30810c0558629f51f03e8d39a24f3b /Doc/library
parent388122d43b2b6bb41774d9680b9ad3bc05682f85 (diff)
downloadcpython-ae7801813c56464e08f7a29c917aa2bc1326831b.zip
cpython-ae7801813c56464e08f7a29c917aa2bc1326831b.tar.gz
cpython-ae7801813c56464e08f7a29c917aa2bc1326831b.tar.bz2
Issue 5077: Add documentation for operator fixer.
Patch by Meador Inge.
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/2to3.rst19
1 files changed, 19 insertions, 0 deletions
diff --git a/Doc/library/2to3.rst b/Doc/library/2to3.rst
index f3be8fa..6786ce9 100644
--- a/Doc/library/2to3.rst
+++ b/Doc/library/2to3.rst
@@ -267,6 +267,25 @@ and off individually. They are described here in more detail.
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