t503.py 344 B

1234567891011121314151617181920
  1. class Comparable:
  2. def __init__(self,value):
  3. self.value = value
  4. def __lt__(self,other):
  5. return self.value < other.value
  6. def __repr__(self):
  7. return "Value :" + str(self.value)
  8. lst = [5,9,2,7]
  9. otherLst = [Comparable(a) for a in lst]
  10. print lst
  11. print otherLst
  12. print min(lst)
  13. print min(otherLst)