Why doesn't `functools.total_ordering` use the existing ordering methods?
25 Apr
2011
25 Apr
'11
6:43 p.m.
Hello, Today I was trying to use `total_ordering` for the first time. I was expecting that in order to implement e.g. `x > y` it would do `not x < y and not x == y`, assuming that `__lt__` and `__eq__` are defined. But I see it just does `y < x`, which is problematic. For example if you have a class that is decorated by `total_ordering`, and implements only `__lt__` and `__eq__`, then trying to do `x < y` will result in infinite recursion. Why not have `total_ordering` work in the way I suggested? Ram.
4720
Age (days ago)
4721
Last active (days ago)
2 comments
3 participants
participants (3)
-
cool-RR
-
Lennart Regebro
-
Raymond Hettinger