fork download
  1. class MyStr(str):
  2. def __lt__(self, other):
  3. print "__lt__",
  4. return NotImplemented
  5. def __gt__(self, other):
  6. print "__gt__",
  7. return NotImplemented
  8. def __cmp__(self, other):
  9. print "__cmp__ called"
  10. return cmp(int(self), int(other))
  11.  
  12. MyStr("0") > MyStr("1")
Success #stdin #stdout 0.08s 8888KB
stdin
Standard input is empty
stdout
__gt__ __lt__ __cmp__ called