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

?? PythonObject -- null coalescing operator for Python objects

Description

When the first argument to the binary null coalescing operator is a Python object, it will be returned unless that object is None, in which case the second argument is returned.

i1 : toPython 3 ?? 4

o1 = 3

o1 : PythonObject of class int
i2 : toPython null

o2 = None

o2 : PythonObject of class NoneType
i3 : oo ?? 5

o3 = 5

For the unary version, the argument itself is returned unless it is None, in which case null is returned.

i4 : ?? toPython 6

o4 = 6

o4 : PythonObject of class int
i5 : ?? toPython null

Ways to use this method:


The source of this document is in Python/doc/comparison.m2:94:0.