implement hash and eq for trade class
This commit is contained in:
parent
df603fdbaa
commit
b647427581
14
src/data.py
14
src/data.py
@ -81,6 +81,20 @@ class Trade():
|
||||
def __str__(self) -> str:
|
||||
return f'Trade: {self.nrItems} {self.item} for {self.amount} {self.currency} in {self.tab} ({self.row}/{self.col}) in {self.league} league'
|
||||
|
||||
def __hash__(self) -> int:
|
||||
return hash((self.nrItems, self.item, self.amount, self.currency, self.tab, self.row, self.col, self.league))
|
||||
|
||||
def __eq__(self, __o: object) -> bool:
|
||||
return (isinstance(__o, self.__class__)
|
||||
and self.nrItems == __o.nrItems
|
||||
and self.item == __o.item
|
||||
and self.amount == __o.amount
|
||||
and self.currency == __o.currency
|
||||
and self.tab == __o.tab
|
||||
and self.row == __o.row
|
||||
and self.col == __o.col
|
||||
and self.league == __o.league)
|
||||
|
||||
def unique_item(self) -> str:
|
||||
return f'{self.item}-{self.tab}-{self.row}/{self.col}-{self.league}'
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user