A class analogous to NaN that has operations defined for any type.
| 165 | ### |
| 166 | # Utility classes |
| 167 | class NotAValueClass(object): |
| 168 | """ |
| 169 | A class analogous to NaN that has operations defined for any type. |
| 170 | """ |
| 171 | def _op(self, other): |
| 172 | return self # Operation with NotAValue returns NotAValue |
| 173 | |
| 174 | def _cmp(self, other): |
| 175 | return False |
| 176 | |
| 177 | __add__ = __radd__ = _op |
| 178 | __sub__ = __rsub__ = _op |
| 179 | __mul__ = __rmul__ = _op |
| 180 | __div__ = __rdiv__ = _op |
| 181 | __truediv__ = __rtruediv__ = _op |
| 182 | __floordiv__ = __rfloordiv__ = _op |
| 183 | |
| 184 | __lt__ = __rlt__ = _op |
| 185 | __gt__ = __rgt__ = _op |
| 186 | __eq__ = __req__ = _op |
| 187 | __le__ = __rle__ = _op |
| 188 | __ge__ = __rge__ = _op |
| 189 | |
| 190 | |
| 191 | NotAValue = NotAValueClass() |