Since you a subclassing unicode
, instances of SufficComparingUnicodeString
can usually be used just like any other Unicode string. So you can just use other.endswith(self)
in your __eq__()
implementation:
class SuffixComparingUnicodeString(unicode):
def __eq__(self, other):
return isinstance(other, unicode) and other.endswith(self)