Learn R Programming

reticulate (version 1.37.0)

==.python.builtin.object: S3 Ops Methods for Python Objects

Description

Reticulate provides S3 Ops Group Generic Methods for Python objects. The methods invoke the equivalent python method of the object.

Usage

# S3 method for python.builtin.object
==(e1, e2)

# S3 method for python.builtin.object !=(e1, e2)

# S3 method for python.builtin.object <(e1, e2)

# S3 method for python.builtin.object >(e1, e2)

# S3 method for python.builtin.object >=(e1, e2)

# S3 method for python.builtin.object <=(e1, e2)

# S3 method for python.builtin.object +(e1, e2)

# S3 method for python.builtin.object -(e1, e2)

# S3 method for python.builtin.object *(e1, e2)

# S3 method for python.builtin.object /(e1, e2)

# S3 method for python.builtin.object %/%(e1, e2)

# S3 method for python.builtin.object %%(e1, e2)

# S3 method for python.builtin.object ^(e1, e2)

# S3 method for python.builtin.object &(e1, e2)

# S3 method for python.builtin.object |(e1, e2)

# S3 method for python.builtin.object !(e1)

# S3 method for python.builtin.object %*%(x, y)

Value

Result from evaluating the Python expression. If either of the arguments to the operator was a Python object with convert=FALSE, then the result will also be a Python object with convert=FALSE set. Otherwise, the result will be converted to an R object if possible.

Arguments

e1, e2, x, y

A python object.

Operator Mappings

R expressionPython expressionFirst python method invoked
x == yx == ytype(x).__eq__(x, y)
x != yx != ytype(x).__ne__(x, y)
x < yx < ytype(x).__lt__(x, y)
x > yx > ytype(x).__gt__(x, y)
x >= yx >= ytype(x).__ge__(x, y)
x <= yx <= ytype(x).__le__(x, y)
+ x + xtype(x).__pos__(x)
- y- xtype(x).__neg__(x)
x + yx + ytype(x).__add__(x, y)
x - yx - ytype(x).__sub__(x, y)
x * yx * ytype(x).__mul__(x, y)
x / yx / ytype(x).__truediv__(x, y)
x %/% yx // ytype(x).__floordiv__(x, y)
x %% yx % ytype(x).__mod__(x, y)
x ^ yx ** ytype(x).__pow__(x, y)
x & yx & ytype(x).__and__(x, y)
x | yx | ytype(x).__or__(x, y)
!x~xtype(x).__not__(x)
x %*% yx @ ytype(x).__matmul__(x, y)

Note: If the initial Python method invoked raises a NotImplemented Exception, the Python interpreter will attempt to use the reflected variant of the method from the second argument. The arithmetic operators will call the equivalent double underscore (dunder) method with an "r" prefix. For instance, when evaluating the expression x + y, if type(x).__add__(x, y) raises a NotImplemented exception, then the interpreter will attempt type(y).__radd__(y, x). The comparison operators follow a different sequence of fallbacks; refer to the Python documentation for more details.