title: How to override equal in python?
body: <p>I need <code>transaction</code> and <code>other_transaction</code> to be equal. Can anyone see what I'm missing?</p>
  <pre><code>    def test_eq_LedgerTransaction():
  &gt;       assert LedgerTransaction.__eq__(transaction, equal_transaction) is True          
  E       assert False is True
  E        +  where False = &lt;function LedgerTransaction.__eq__ at 0x7f49c3183550&gt;(transaction, equal_transaction)
  E        +    where &lt;function LedgerTransaction.__eq__ at 0x7f49c3183550&gt; = LedgerTransaction.__eq__
  </code></pre>
  <p>Code</p>
  <pre><code>class LedgerTransaction():
      def __init__(self, date: str, payee: str, amount: float):
          self.date = date
          self.payee = payee
          self.amount = float(amount)
  
      def __eq__(self, other):
          return self == other
  
      def __repr__(self):
          return f'Transaction:{self.date, self.payee, self.amount}'
  
      def __hash__(self):
          return hash((self.date, self.payee, self.amount))
  
  
  # Tests
  import pytest
  
  
  @pytest.fixture
  def transaction():
      return LedgerTransaction(&quot;2021/12/31&quot;, &quot;transaction&quot;, 5.0)
  
  
  @pytest.fixture
  def equal_transaction():
      return LedgerTransaction(&quot;2021/12/31&quot;, &quot;transaction&quot;, 5.0)
  
  
  @pytest.fixture
  def other_transaction():
      return LedgerTransaction(&quot;2021/12/31&quot;, &quot;peach&quot;, 5.0)
  
  
  def test_eq_LedgerTransaction():
      assert LedgerTransaction.__eq__(transaction, equal_transaction) is True
      assert LedgerTransaction.__eq__(transaction, other_transaction) is False
  </code></pre>