__lt__ and __repr__, but not __eq__.
class Price:
def __init__(self, cents):
self.cents = cents
def __lt__(self, other):
return self.cents < other.cents
def __repr__(self):
return "c" + str(self.cents)
tags = [Price(5), Price(2), Price(9)]
print(sorted(tags), max(tags), Price(3) == Price(3))
What does the program print?Log in to join the discussion.
Loading…