Python: Why does the int class not have rich comparison operators like `__lt__()`?
问题 Mostly curious. I've noticed (at least in py 2.6 and 2.7) that a float has all the familiar rich comparison functions: __lt__() , __gt__ , __eq__ , etc. >>> (5.0).__gt__(4.5) True but an int does not >>> (5).__gt__(4) Traceback (most recent call last): File "<input>", line 1, in <module> AttributeError: 'int' object has no attribute '__gt__' Which is odd to me, because the operator itself works fine >>> 5 > 4 True Even strings support the comparison functions >>> "hat".__gt__("ace") True but