title: Override __eq__ with more logic
body: <p>I have the following python classes</p>
  <pre><code>class Message:
  
      def __init__(self, start_date, attributes):
          self.start_date = start_date
          self.attributes = attributes
  
      def __eq__(self, other):
          if not isinstance(other, Message):
              return False
  
          if not self.attributes == other.attrubutes:
              return False
  
          are_consecutive_dates = False
          self_start_date= datetime.strptime(self.start_date, '%Y-%m-%d')
          other_start_date= datetime.strptime(other.start_date, '%Y-%m-%d')
          
          if not abs(self_start_date.toordinal() - other_start_date.toordinal()) == 1:
              return False
  
          return True
  
  
  class Attribute:
  
      def __init__(self, attribute_a, attribute_b):
          self.attribute_a = attribute_a
          self.attribute_b = attribute_b
  
      def __eq__(self, other):
          if not isinstance(other, Attribute):
              return False
  
          if not self.attribute_a == other.attribute_a:
              return False
  
          if not self.attribute_b == other.attribute_b:
              return False
  
          return True
  </code></pre>
  <p>From a business perspective, two messages are equals if have the same attributes and have consecutive dates</p>
  <p>I have two questions:</p>
  <ol>
  <li><p>Is valid to have some business logic inside the <code>__eq__</code>(like the dates are consecutive)?</p>
  </li>
  <li><p>If the above is valid, I would like to create a set and pass the
  Messages instances and discard the ones that are equals by the definition I just wrote, so
  how I need to override the <code>__hash__</code>?</p>
  </li>
  </ol>