def __repr__(self): elems = [] prevk = 0 if len(self.elements) > 0: k = self.keys[0] elems.append(str(k) + ' -> ' + tiny_repr(self.elements[k])) prevk = self.keys[0] for i in xrange(1, len(self.elements)): nextk = self.keys[i] if nextk <= prevk + 2: while prevk < nextk - 1: elems.append('__') prevk += 1 elems.append(tiny_repr(self.elements[nextk])) else: elems.append('\n... ' + str(nextk) + ' -> ' + tiny_repr(self.elements[nextk])) prevk = nextk return '[' + ', '.join(elems) + ']'