comparison data_schema/__init__.py @ 45:8a560e0c3180

Implement __ne__ also where __eq__ is implemented
author Franz Glasner <f.glasner@feldmann-mg.com>
date Wed, 02 Aug 2023 13:58:25 +0200
parents ea8c2d01a9d9
children 92ae1e882cef
comparison
equal deleted inserted replaced
44:ea8c2d01a9d9 45:8a560e0c3180
235 and (self.hint == other.hint) 235 and (self.hint == other.hint)
236 and (self.context == other.context) 236 and (self.context == other.context)
237 and (self.cause == other.cause) 237 and (self.cause == other.cause)
238 and (self.index == other.index)) 238 and (self.index == other.index))
239 239
240 def __ne__(self, other):
241 #
242 # While the default in Python3 is sensible implementing is recommended
243 # when a built-in __eq__ is overwritten (Raymond Hettinger).
244 #
245 # Do not use not self == other because NotImplemented is not handled
246 # properly in some early Python versions (including Py2).
247 #
248 equal = self.__eq__(other)
249 return NotImplemented if equal is NotImplemented else not equal
250
240 def __getstate__(self): 251 def __getstate__(self):
241 return (1, self.code, self.severity, self.hint, self.context, 252 return (1, self.code, self.severity, self.hint, self.context,
242 self.cause, self.index) 253 self.cause, self.index)
243 254
244 def __setstate__(self, state): 255 def __setstate__(self, state):