diff options
Diffstat (limited to 'Doc/library/2to3.rst')
-rw-r--r-- | Doc/library/2to3.rst | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/Doc/library/2to3.rst b/Doc/library/2to3.rst index de31251..b3efeab 100644 --- a/Doc/library/2to3.rst +++ b/Doc/library/2to3.rst @@ -141,7 +141,7 @@ and off individually. They are described here in more detail. .. 2to3fixer:: exec - Converts the :keyword:`exec` statement to the :func:`exec` function. + Converts the ``exec`` statement to the :func:`exec` function. .. 2to3fixer:: execfile @@ -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 @@ -274,7 +293,7 @@ and off individually. They are described here in more detail. .. 2to3fixer:: print - Converts the :keyword:`print` statement to the :func:`print` function. + Converts the ``print`` statement to the :func:`print` function. .. 2to3fixer:: raise |