This commit is contained in:
Mike Bloy 2023-10-28 19:08:34 -05:00
parent 704290b1a2
commit 8d9e4b4cb8

View File

@ -7,6 +7,18 @@ class Stock:
self.shares = shares
self.price = price
def __repr__(self):
return f"Stock({self.name!r}, {self.shares!r}, {self.price!r})"
def __eq__(self, other):
if not isinstance(other, Stock):
return False
return (self.name, self.shares, self.price) == (
other.name,
other.shares,
other.price,
)
@classmethod
def from_row(cls, row):
values = [func(val) for func, val in zip(cls._types, row)]