Tweeted By @python_tip
By default, Python compare objects using their ids. Consider the following class:
— Daily Python Tip (@python_tip) August 16, 2018
class Number:
def __init__(self, x):
self.x = x
n1 = Number(1)
n2 = Number(1)
n1 == n2 # False 😲😲
The elegant solution to this problem is to use #dataclasses https://t.co/wxBtxfyLPR