Код не видит магического метода

Рейтинг: 1Ответов: 0Опубликовано: 10.07.2023

При сравнении выдает not supported between instances of 'MoneyR' and 'MoneyR'

class MoneyR:
    def __init__(self, cb = None, volume = 0):
        self.__cb = cb
        self.__volume = volume
    def set_sb(self, value):
        self.__sb = value
    def get_sb(self):
        return self.__sb
    def set_volume(self, value):
        self.__volume = value
    def get_volume(self):
        return self.__volume
    sb = property(get_sb, set_sb)
    volume = property(get_volume, set_volume)
    def __qt__(self, other):
        if self.__cb is not None and other.__cb is not None:
            if type(other) == MoneyR:
                d = other.volume
            elif type(other) == MoneyD:
                d = other.volume * CentralBank.rates['dollar']
            else:
                d = other.volume * CentralBank.rates['euro']
            return self.volume > d
        else:
            raise ValueError("Неизвестен курс валют.")
    def __qe__(self, other):
        if self.__cb is not None and other.__cb is not None:
            if type(other) == MoneyR:
                d = other.volume
            elif type(other) == MoneyD:
                d = other.volume * CentralBank.rates['dollar']
            else:
                d = other.volume * CentralBank.rates['euro']
            return self.volume >= d
        else:
            raise ValueError("Неизвестен курс валют.")
    def __eq__(self, other):
        if self.__cb is not None and other.__cb is not None:
            if type(other) == MoneyR:
                d = other.volume
            elif type(other) == MoneyD:
                d = other.volume * CentralBank.rates['dollar']
            else:
                d = other.volume * CentralBank.rates['euro']
            return abs(self.volume - d) <= 0.1
        else:
            raise ValueError("Неизвестен курс валют.")
print(MoneyR(100) > MoneyR(5))

Ответы

Ответов пока нет.