> If you want to compare partial keys, often the simplest approach is to > use tuples as keys, with the elements of the tuple being the "parts" of > the key. Python's standard tuple comparison mechanism takes care of the > rest.
Right, but suppose it's expensive to generate each part of the key - e.g. a database query or some kind of hash, so it doesn't make sense to compute the whole key in advance if the first part is sufficient to establish an ordering most of the time. This is what I had in mind (I should have been more clear about that) Sure, you could put together a lazy evaluation object to use for elements of the tuple, but this again becomes equivalent to writing a __cmp__ function... -- http://mail.python.org/mailman/listinfo/python-list