# operator

Starlark module for working with operators interface.

This module exports a set of functions 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. This is a pure Python implementation of the module.

Similar to [operator in Python](https://github.com/python/cpython/blob/main/Lib/operator.py).

## operator.abs(a)

Same as abs(a).

## operator.add(lhs, rhs)

A closure implementing a binary operation in Python.

## operator.and(lhs, rhs)

A closure implementing a binary operation in Python.

## operator.concat(a, b)

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

## operator.contains(a, b)

Same as b in a (note reversed operands).

## operator.countOf(a, b)

Return the number of times b occurs in a.

## operator.delitem(a, b)

Same as del a\[b].

## operator.eq(lhs, rhs)

Implement the rich comparison a {operator} b.

## operator.floordiv(lhs, rhs)

A closure implementing a binary operation in Python.

## operator.ge(lhs, rhs)

Implement the rich comparison a {operator} b.

## operator.getitem(a, b)

Same as a\[b].

## operator.gt(lhs, rhs)

Implement the rich comparison a {operator} b.

## operator.iadd(a, b)

Same as a += b.

## operator.iand(a, b)

Same as a &= b.

## operator.iconcat(a, b)

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

## operator.ifloordiv(a, b)

Same as a //= b.

## operator.ilshift(a, b)

Same as a <<= b.

## operator.imatmul(a, b)

Same as a @= b.

## operator.imod(a, b)

Same as a %= b.

## operator.imul(a, b)

Same as a \*= b.

## operator.index(a)

Same as a.**index**().

## operator.indexOf(a, b)

Return the first index of b in a.

## operator.inv(object\_)

A closure implementing a unary arithmetic operation.

## operator.invert(object\_)

A closure implementing a unary arithmetic operation.

## operator.ior(a, b)

Same as a |= b.

## operator.ipow(a, b)

Same as a \*\*= b.

## operator.irshift(a, b)

Same as a >>= b.

## operator.is\_(a, b)

Same as a is b.

## operator.is\_not(a, b)

Same as a is not b.

## operator.isub(a, b)

Same as a -= b.

## operator.itruediv(a, b)

Same as a /= b.

## operator.ixor(a, b)

Same as a ^= b.

## operator.le(lhs, rhs)

Implement the rich comparison a {operator} b.

## operator.length\_hint(obj, default=0)

As defined in PEP 424. 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.

## operator.lshift(lhs, rhs)

A closure implementing a binary operation in Python.

## operator.lt(lhs, rhs)

Implement the rich comparison a {operator} b.

## operator.matmul(lhs, rhs)

A closure implementing a binary operation in Python.

## operator.mod(lhs, rhs)

A closure implementing a binary operation in Python.

## operator.mul(lhs, rhs)

A closure implementing a binary operation in Python.

## operator.ne(lhs, rhs)

Implement the rich comparison a {operator} b.

## operator.neg(object\_)

A closure implementing a unary arithmetic operation.

## operator.not\_(a)

Same as not a.

## operator.or\_(lhs, rhs)

A closure implementing a binary operation in Python.

## operator.pos(object\_)

A closure implementing a unary arithmetic operation.

## operator.pow(lhs, rhs)

A closure implementing a binary operation in Python.

## operator.rshift(lhs, rhs)

A closure implementing a binary operation in Python.

## operator.setitem(a, b, c)

Same as a\[b] = c.

## operator.sub(lhs, rhs)

A closure implementing a binary operation in Python.

## operator.truediv(lhs, rhs)

A closure implementing a binary operation in Python.

## operator.truth(a)

Return True if a is true, False otherwise.

## operator.xor(lhs, rhs)

A closure implementing a binary operation in Python.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.verygoodsecurity.com/vault/developer-tools/larky/library-api/operator.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
