# operator - pydoc - phpman

Help on module operator:

## NAME
    operator - Operator interface.

## MODULE REFERENCE
    <https://docs.python.org/3.10/library/operator.html>

    The following documentation is automatically generated from the Python
    source files.  It may be incomplete, incorrect or include features that
    are considered implementation detail and may vary between Python
    implementations.  When in doubt, consult the module reference at the
    location listed above.

## DESCRIPTION
    This module exports a set of functions implemented in C corresponding
    to the intrinsic operators of Python.  For example, operator.add(x, y)
    is equivalent to the expression x+y.  The function names are those
    used for special methods; variants without leading and trailing
    '__' are also provided for convenience.

## CLASSES
    builtins.object
        attrgetter
        itemgetter
        methodcaller

### class attrgetter
     |  attrgetter(attr, ...) --> attrgetter object
     |
     |  Return a callable object that fetches the given attribute(s) from its operand.
     |  After f = attrgetter('name'), the call f(r) returns r.name.
     |  After g = attrgetter('name', 'date'), the call g(r) returns (r.name, r.date).
     |  After h = attrgetter('name.first', 'name.last'), the call h(r) returns
     |  (r.name.first, r.name.last).
     |
     |  Methods defined here:
     |
     |  __call__(self, /, *args, **kwargs)
     |      Call self as a function.
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __reduce__(...)
     |      Return state information for pickling
     |
     |  __repr__(self, /)
     |      Return repr(self).
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.

### class itemgetter
     |  itemgetter(item, ...) --> itemgetter object
     |
     |  Return a callable object that fetches the given item(s) from its operand.
     |  After f = [itemgetter(2)](https://www.chedong.com/phpMan.php/man/itemgetter/2/markdown), the call f(r) returns r[2].
     |  After g = itemgetter(2, 5, 3), the call g(r) returns (r[2], r[5], r[3])
     |
     |  Methods defined here:
     |
     |  __call__(self, /, *args, **kwargs)
     |      Call self as a function.
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __reduce__(...)
     |      Return state information for pickling
     |
     |  __repr__(self, /)
     |      Return repr(self).
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.

### class methodcaller
     |  methodcaller(name, ...) --> methodcaller object
     |
     |  Return a callable object that calls the given method on its operand.
     |  After f = methodcaller('name'), the call f(r) returns r.name().
     |  After g = methodcaller('name', 'date', foo=1), the call g(r) returns
     |  r.name('date', foo=1).
     |
     |  Methods defined here:
     |
     |  __call__(self, /, *args, **kwargs)
     |      Call self as a function.
     |
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |
     |  __reduce__(...)
     |      Return state information for pickling
     |
     |  __repr__(self, /)
     |      Return repr(self).
     |
     |  ----------------------------------------------------------------------
     |  Static methods defined here:
     |
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.

## FUNCTIONS
    __abs__ = abs(a, /)
        Same as abs(a).

    __add__ = add(a, b, /)
        Same as a + b.

    __and__ = and_(a, b, /)
        Same as a & b.

    __concat__ = concat(a, b, /)
        Same as a + b, for a and b sequences.

    __contains__ = contains(a, b, /)
        Same as b in a (note reversed operands).

    __delitem__ = delitem(a, b, /)
        Same as del a[b].

    __eq__ = eq(a, b, /)
        Same as a == b.

    __floordiv__ = floordiv(a, b, /)
        Same as a // b.

    __ge__ = ge(a, b, /)
        Same as a >= b.

    __getitem__ = getitem(a, b, /)
        Same as a[b].

    __gt__ = gt(a, b, /)
        Same as a > b.

    __iadd__ = iadd(a, b, /)
        Same as a += b.

    __iand__ = iand(a, b, /)
        Same as a &= b.

    __iconcat__ = iconcat(a, b, /)
        Same as a += b, for a and b sequences.

    __ifloordiv__ = ifloordiv(a, b, /)
        Same as a //= b.

    __ilshift__ = ilshift(a, b, /)
        Same as a <<= b.

    __imatmul__ = imatmul(a, b, /)
        Same as a @= b.

    __imod__ = imod(a, b, /)
        Same as a %= b.

    __imul__ = imul(a, b, /)
        Same as a *= b.

    __index__ = index(a, /)
        Same as a.__index__()

    __inv__ = inv(a, /)
        Same as ~a.

    __invert__ = invert(a, /)
        Same as ~a.

    __ior__ = ior(a, b, /)
        Same as a |= b.

    __ipow__ = ipow(a, b, /)
        Same as a **= b.

    __irshift__ = irshift(a, b, /)
        Same as a >>= b.

    __isub__ = isub(a, b, /)
        Same as a -= b.

    __itruediv__ = itruediv(a, b, /)
        Same as a /= b.

    __ixor__ = ixor(a, b, /)
        Same as a ^= b.

    __le__ = le(a, b, /)
        Same as a <= b.

    __lshift__ = lshift(a, b, /)
        Same as a << b.

    __lt__ = lt(a, b, /)
        Same as a < b.

    __matmul__ = matmul(a, b, /)
        Same as a @ b.

    __mod__ = mod(a, b, /)
        Same as a % b.

    __mul__ = mul(a, b, /)
        Same as a * b.

    __ne__ = ne(a, b, /)
        Same as a != b.

    __neg__ = neg(a, /)
        Same as -a.

    __not__ = not_(a, /)
        Same as not a.

    __or__ = or_(a, b, /)
        Same as a | b.

    __pos__ = pos(a, /)
        Same as +a.

    __pow__ = pow(a, b, /)
        Same as a ** b.

    __rshift__ = rshift(a, b, /)
        Same as a >> b.

    __setitem__ = setitem(a, b, c, /)
        Same as a[b] = c.

    __sub__ = sub(a, b, /)
        Same as a - b.

    __truediv__ = truediv(a, b, /)
        Same as a / b.

    __xor__ = xor(a, b, /)
        Same as a ^ b.

### abs
        Same as abs(a).

### add
        Same as a + b.

### and_
        Same as a & b.

### concat
        Same as a + b, for a and b sequences.

### contains
        Same as b in a (note reversed operands).

### countOf
        Return the number of items in a which are, or which equal, b.

### delitem
        Same as del a[b].

### eq
        Same as a == b.

### floordiv
        Same as a // b.

### ge
        Same as a >= b.

### getitem
        Same as a[b].

### gt
        Same as a > b.

### iadd
        Same as a += b.

### iand
        Same as a &= b.

### iconcat
        Same as a += b, for a and b sequences.

### ifloordiv
        Same as a //= b.

### ilshift
        Same as a <<= b.

### imatmul
        Same as a @= b.

### imod
        Same as a %= b.

### imul
        Same as a *= b.

### index
        Same as a.__index__()

### indexOf
        Return the first index of b in a.

### inv
        Same as ~a.

### invert
        Same as ~a.

### ior
        Same as a |= b.

### ipow
        Same as a **= b.

### irshift
        Same as a >>= b.

### is_
        Same as a is b.

### is_not
        Same as a is not b.

### isub
        Same as a -= b.

### itruediv
        Same as a /= b.

### ixor
        Same as a ^= b.

### le
        Same as a <= b.

### length_hint
        Return an estimate of the number of items in obj.

        This is useful for presizing containers when building from an iterable.

        If the object supports len(), the result will be exact.
        Otherwise, it may over- or under-estimate by an arbitrary amount.
        The result will be an integer >= 0.

### lshift
        Same as a << b.

### lt
        Same as a < b.

### matmul
        Same as a @ b.

### mod
        Same as a % b.

### mul
        Same as a * b.

### ne
        Same as a != b.

### neg
        Same as -a.

### not_
        Same as not a.

### or_
        Same as a | b.

### pos
        Same as +a.

### pow
        Same as a ** b.

### rshift
        Same as a >> b.

### setitem
        Same as a[b] = c.

### sub
        Same as a - b.

### truediv
        Same as a / b.

### truth
        Return True if a is true, False otherwise.

### xor
        Same as a ^ b.

## DATA
    __all__ = ['abs', 'add', 'and_', 'attrgetter', 'concat', 'contains', '...

## FILE
    /usr/lib/python3.10/operator.py


