Money(10, 'INR') instances are unequal (identity comparison). Implement __eq__ comparing amount and currency — returning NotImplemented for foreign types — and a consistent __hash__ so equal Money objects can live in sets and as dict keys.Money(10, 'INR') == Money(10, 'INR')
True
Value semantics replace identity.
len({Money(10, 'INR'), Money(10, 'INR')})1
Equal objects hash identically and collapse in a set.
Compare a tuple of both fields.
hash((self.amount, self.currency)) keeps the contract.