implement equality
This commit is contained in:
parent
132d51777a
commit
7cfbe2284d
2 changed files with 20 additions and 4 deletions
|
|
@ -10,10 +10,15 @@ class CurrencyPair:
|
|||
self.from_currency = from_currency
|
||||
self.to_currency = to_currency
|
||||
|
||||
def __str__(self):
|
||||
return str(self.from_currency) + str(self.to_currency)
|
||||
|
||||
def get_reverse_pair(self) -> "CurrencyPair":
|
||||
return CurrencyPair(
|
||||
from_currency=self.to_currency, to_currency=self.from_currency
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return str(self.from_currency) + str(self.to_currency)
|
||||
|
||||
def __eq__(self, other: "CurrencyPair") -> bool:
|
||||
return (self.from_currency == other.from_currency) and (
|
||||
self.to_currency == other.to_currency
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue