完成以下代码的最自然方法是什么?
import functools
@functools.total_ordering
class X:
def __init__(self, a):
self._a = a
def __eq__(self, other):
if not isinstance(other, X):
return False
return self._a == other._a
def __lt__(self, other):
if not isinstance(other, X):
return ... // what should go here?
return self._a < other._a
if __name__ == '__main__':
s = [2, 'foo', X(2)]
s.sort()
print s