[Python-Dev] Why doesn't functools.total_ordering
use the existing ordering methods? (original) (raw)
Raymond Hettinger raymond.hettinger at gmail.com
Mon Apr 25 21:13:54 CEST 2011
- Previous message: [Python-Dev] Why doesn't `functools.total_ordering` use the existing ordering methods?
- Next message: [Python-Dev] Why doesn't `functools.total_ordering` use the existing ordering methods?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Apr 25, 2011, at 11:43 AM, cool-RR wrote:
Today I was trying to use
totalordering
for the first time. I was expecting that in order to implement e.g.x > y
it would donot x < y and not x == y
, assuming that_lt_
and_eq_
are defined.
This was fixed. The current code has:
convert = {
'__lt__': [('__gt__', lambda self, other: not (self < other or self == other)),
('__le__', lambda self, other: self < other or self == other),
('__ge__', lambda self, other: not self < other)],
'__le__': [('__ge__', lambda self, other: not self <= other or self == other),
('__lt__', lambda self, other: self <= other and not self == other),
('__gt__', lambda self, other: not self <= other)],
'__gt__': [('__lt__', lambda self, other: not (self > other or self == other)),
('__ge__', lambda self, other: self > other or self == other),
('__le__', lambda self, other: not self > other)],
'__ge__': [('__le__', lambda self, other: (not self >= other) or self == other),
('__gt__', lambda self, other: self >= other and not self == other),
('__lt__', lambda self, other: not self >= other)]
}
Why not have
totalordering
work in the way I suggested?
To avoid needless posts, you should use the tracker.
Raymond
- Previous message: [Python-Dev] Why doesn't `functools.total_ordering` use the existing ordering methods?
- Next message: [Python-Dev] Why doesn't `functools.total_ordering` use the existing ordering methods?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]