You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
programming-basics-2022/08_python/magic/hasheq.py

21 lines
398 B

class MADATA:
def __init__(
self,
a: int,
b: int,
c: int,
):
self.a = a
self.b = b
self.c = c
@property
def _tup_view(self):
return self.a, self.b, self.c
def __hash__(self):
return hash(self._tup_view)
def __eq__(self, o):
return isinstance(o, type(self)) and o._tup_view == self._tup_view