# Jython Issue with Key Comparison in Dicts class Wrapper(object): def __init__(self, content): self.content = content def __hash__(self): return hash(self.content) def __cmp__(self, other): if isinstance(other, Wrapper): return cmp(self.content, other.content) return cmp(self.content, other) dct = {1: 0, "ABC": 1} one = Wrapper(1) text = Wrapper("ABC") dct[one] # ok, returns 0 dct[text] == 1 # raises a KeyError instead of returning 1