ex36
This commit is contained in:
parent
704290b1a2
commit
8d9e4b4cb8
12
stock.py
12
stock.py
@ -7,6 +7,18 @@ class Stock:
|
|||||||
self.shares = shares
|
self.shares = shares
|
||||||
self.price = price
|
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
|
@classmethod
|
||||||
def from_row(cls, row):
|
def from_row(cls, row):
|
||||||
values = [func(val) for func, val in zip(cls._types, row)]
|
values = [func(val) for func, val in zip(cls._types, row)]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user