def METHOD_NAME(self, x, level):
    try:
        s = builtins.repr(x)
        # Bugs in x.__repr__() can cause arbitrary
        # exceptions -- then make up something
    except Exception:
        return '<%s instance at %#x>' % (x.__class__.__name__, id(x))
    if len(s) > self.maxother:
        i = max(0, (self.maxother-3)//2)
        j = max(0, self.maxother-3-i)
        s = s[:i] + '...' + s[len(s)-j:]
    return s