Macaulay2 » Documentation
Packages » Python » PythonObject » PythonObject xor PythonObject
next | previous | forward | backward | up | index | toc

PythonObject xor PythonObject -- logical exclusive disjunction of Python objects

Description

Perform the logical exclusive disjunction ("xor") operation on Python objects.

i1 : toPython true xor toPython true

o1 = False

o1 : PythonObject of class bool

If one of the arguments is a Macaulay2 object, then it is first converted to a Python object.

i2 : toPython true xor false

o2 = True

o2 : PythonObject of class bool
i3 : false xor toPython true

o3 = True

o3 : PythonObject of class bool

Unlike Macaulay2, Python supports using xor with non-boolean objects. If exactly one of the arguments is truthy, then it will return that argument. Otherwise, it will return False.

i4 : toPython 0 xor toPython "foo"

o4 = foo

o4 : PythonObject of class str
i5 : toPython 5 xor toPython ""

o5 = 5

o5 : PythonObject of class int
i6 : toPython 6 xor toPython "bar"

o6 = False

o6 : PythonObject of class bool

See also

Ways to use this method:


The source of this document is in Python/doc/logical.m2:149:0.