Guest User

Untitled

a guest
Nov 20th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. class ArtisanalClass(object):
  2. def __init__(self, a, b):
  3. self.a = a
  4. self.b = b
  5.  
  6. def __repr__(self):
  7. return "ArtisanalClass(a={}, b={})".format(self.a, self.b)
  8.  
  9. def __eq__(self, other):
  10. if other.__class__ is self.__class__:
  11. return (self.a, self.b) == (other.a, other.b)
  12.  
  13. return NotImplemented
  14.  
  15. def __ne__(self, other):
  16. result = self.__eq__(other)
  17. if result is NotImplemented:
  18. return NotImplemented
  19.  
  20. return not result
  21.  
  22. def __lt__(self, other):
  23. if other.__class__ is self.__class__:
  24. return (self.a, self.b) < (other.a, other.b)
  25.  
  26. return NotImplemented
  27.  
  28. def __le__(self, other):
  29. if other.__class__ is self.__class__:
  30. return (self.a, self.b) <= (other.a, other.b)
  31.  
  32. return NotImplemented
  33.  
  34. def __gt__(self, other):
  35. if other.__class__ is self.__class__:
  36. return (self.a, self.b) > (other.a, other.b)
  37.  
  38. return NotImplemented
  39.  
  40. def __ge__(self, other):
  41. if other.__class__ is self.__class__:
  42. return (self.a, self.b) >= (other.a, other.b)
  43.  
  44. return NotImplemented
  45.  
  46. def __hash__(self):
  47. return hash((self.a, self.b))
Add Comment
Please, Sign In to add comment