On Thu, Oct 13, 2011 at 7:06 AM, Jim Jewett
On Wed, Oct 12, 2011 at 11:18 PM, Guido van Rossum
wrote: (I'm also -1 on adding ordering comparisons; there's little disagreement on that issue.)
If I had a time machine, I would allow comparisons to return "unordered" as well. Right now, objects are comparable or not based strictly on the type, even though comparison is inherently about the values.
I think that
range(3) < range(10)
is obviously true, even though it isn't clear whether or not
range(3, 15, 2) < range(7, -8, -1)
is true.
Here we err by not allowing the first comparison; other objects (like dicts) we err by forcing an arbitrary ordering.
Have you used Python3 lately? It doesn't allow dict ordering. In general Python expresses unordered by raising an exception (often TypeError). Even though range(1) is "obviously" < range(2), there are so many unobvious cases that supporting this one special case isn't worth it. -- --Guido van Rossum (python.org/~guido)