On 12/19/05, Jim Jewett <[EMAIL PROTECTED]> wrote: > Unfortunately, one very common use case of comparisons is to get a > canonical order. If the order is sensible, all the better, but that > is not strictly required. One of Python's selling points (especially > compared to Java) is that getting a canonical order "just works", even > if the objects being sorted are not carefully homogenized by hand. > Python itself relies on this when comparing same-length dictionaries.
While I agree that this is a useful property, and I'd like it to be true, it isn't even today: >>> import Numeric >>> a = Numeric.array((1,2,3)) >>> a array([1, 2, 3]) >>> sorted([a, (1,2,3), 1, 2, '123']) Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: function not supported for these types, and can't coerce to supported types >>> a < '123' Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: function not supported for these types, and can't coerce to supported types >>> Numeric arrays are the canonical example of an "awkward case" when discussing comparisons... OTOH, I'm not sure I want to see more "awkward cases" added. Paul. _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com