Teks sumber — English
Terjemahan — Bahasa Indonesia
The :mod:`!operator` module exports a set of efficient functions corresponding to the intrinsic operators of Python. For example, ``operator.add(x, y)`` is equivalent to the expression ``x+y``. Many function names are those used for special methods, without the double underscores. For backward compatibility, many of these have a variant with the double underscores kept. The variants without the double underscores are preferred for clarity.
Perform "rich comparisons" between *a* and *b*. Specifically, ``lt(a, b)`` is equivalent to ``a < b``, ``le(a, b)`` is equivalent to ``a <= b``, ``eq(a, b)`` is equivalent to ``a == b``, ``ne(a, b)`` is equivalent to ``a != b``, ``gt(a, b)`` is equivalent to ``a > b`` and ``ge(a, b)`` is equivalent to ``a >= b``. Note that these functions can return any value, which may or may not be interpretable as a Boolean value. See :ref:`comparisons` for more information about rich comparisons.
Return :const:`True` if *obj* is true, and :const:`False` otherwise. This is equivalent to using the :class:`bool` constructor.
Return *a* converted to an integer. Equivalent to ``a.__index__()``.
Equivalent to::
Setara dengan::
Many operations have an "in-place" version. Listed below are functions providing a more primitive access to in-place operators than the usual syntax does; for example, the :term:`statement` ``x += y`` is equivalent to ``x = operator.iadd(x, y)``. Another way to put it is to say that ``z = operator.iadd(x, y)`` is equivalent to the compound statement ``z = x; z += y``.
``a = iadd(a, b)`` is equivalent to ``a += b``.
``a = iand(a, b)`` is equivalent to ``a &= b``.
``a = iconcat(a, b)`` is equivalent to ``a += b`` for *a* and *b* sequences.
``a = ifloordiv(a, b)`` is equivalent to ``a //= b``.
``a = ilshift(a, b)`` is equivalent to ``a <<= b``.
``a = imod(a, b)`` is equivalent to ``a %= b``.
``a = imul(a, b)`` is equivalent to ``a *= b``.
``a = imatmul(a, b)`` is equivalent to ``a @= b``.
``a = ior(a, b)`` is equivalent to ``a |= b``.
``a = ipow(a, b)`` is equivalent to ``a **= b``.
``a = irshift(a, b)`` is equivalent to ``a >>= b``.
``a = isub(a, b)`` is equivalent to ``a -= b``.
``a = itruediv(a, b)`` is equivalent to ``a /= b``.
``a = ixor(a, b)`` is equivalent to ``a ^= b``.