friendlysam.opt.Eq

class friendlysam.opt.Eq

The relation “equals”.

Warning

The operator == is reserved for checking object similarity, just like we are used to in Python. To create the relation “x equals y”, use Eq:

>>> from friendlysam import Eq
>>> my_var = Variable('x')
>>> my_var == 1
False
>>> print(Eq(my_var, 1))
x == 1

Examples

>>> x = Variable('x')
>>> x == 3 # Don't do this!
False
>>> equality = Eq(x, 3) # Do this instead.
>>> equality
<friendlysam.opt.Eq at 0x...>
>>> x.value = 3
>>> equality.value
True
>>> x.value = 4
>>> equality.value
False
Eq.create(*args) Classmethod to create a new object.
Eq.evaluate([replace, evaluators]) Evaluate the expression recursively.
Eq.args This property holds the arguments of the operation.
Eq.leaves The leaves of the expression tree.
Eq.value The concrete value of the expression, if possible.
Eq.variables This property gives all leaves which are instances of Variable.