On Jul 8, 2005, at 12:31 PM, David Binger wrote: > If the other is an instance of Persistent with no _id > attribute, I think this should really raise an exception. I have modified it again since... def __cmp__(self, other): if self is other: return 0 try: return cmp( (self._container.__class__.__name__, self._id), (other._container.__class__.__name__, other._id) ) except AttributeError: return cmp(self._id, other) Because, the id can be the same for different items in different containers. I am not really worried so much about raising the AttributeError... but I am not sure in what contexts a p_item will be compared to arbitrarily some other kind of object. It will certainly never happen during the comparison of btree keys (in moellus)... I just lazily threw in that last-ditch cmp, to not have to deal with it properly, for now (and, as i said, i think this situation should not be pertinent to my application). Do you think that replacing the last-ditch comparison with: return cmp(self._id, str(other)) is a better idea? It would be stable at least... > I think you should specify "except AttributeError" > in cases like this. Of course.... Thanks.